RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Simple Script I've been working with

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 75
What the...?
Code: [Select]
#                     IXs_Map_Script
#                    By: IXFURU
# ----------------------------------------------------------------------------------
#You can use this script in any project you want.  Please give credit at some point
#in your project if you do.  If you use it for a commercial project, please contact
#me first.  webmaster@jibbes.com
#-----------------------------------------------------------------------------------
#
#
#
# This script will allow you to tie images to switches in your project.  Each
#switch will represent a map in your game.  Be sure to activate the switch using
#a parallel event when you enter a new map which will be marked on the map,
#using images.   If you plan on having more than 20 marked areas, it is imperative
#that you go retrieve some kind of limit break WHICH INCLUDES a limit break on
#the amount of pics one can have/display. 
#
#The script requires that you supply a WORLD_MAP_IMAGE which needs to be of a size
#which will act as a background when the world map scene is called. 
#
#IMPORTANT:  This script will also require you to add images for each visible
#landmark which will also appear on the map when it's appropriate switch is on.
#
#
#
##Another Thing:   
#You'll be using the first image (that is picture in viewport 1) to be the
#WORLD MAP and the 20th picture to be Player Position.  That said, if you don't
#have a limit breaker for pics, you'll only actually have 18 location images
#available to you at a single time, for that is the default amount of viewports.
#
#
#DONT MESS WITH THE module line
#---------------------------------------------------------------------------------
module Map_Script
#--------------------------------------------------------------------------------
#EDITTABLE REGION 1
#Here's where you set up the which map scene button which will call the World Map.
#Change the letter after the 'Input::' to whatever button you wish to call the Map.
#This button will both open AND close the scene.
#
WORLD_MAP_KEY = Input::R
#
#Next step is to set an image to be the background or main map when the World_Map
#Scene is called.  You'll have to supply the image in the image/pictures folder.
#
WORLD_MAP_IMAGE = 'world map'
#
#Now, tie an image which will represent where you are currently on the map. Just
#replace the 'red dot' image with the name of an image fouund in the resources under
#pictures folder.
#
CURRENT_POSITION = 'red dot'
#
#Lastly, you need to use two in-game variables to which needs to run be based
#on map_id.  This is done easily enough in the control variables section. These
#will be set below and will be set as WORLD MAP X and WORLD MAP Y.   Once again,
#you can set these variables each time a new map is visited.  Make a parallel
#event running out of reach of player character.  It will run whenever the
#player enters a map which changes his/her place on the WORLD MAP scene.
#
#
#It should look something like this:
#
#Control Variable[WORLD_MAP_X] = constant [a]
#Control Variable[WORLD_MAP_Y] = constant [b]
#Control Switches[z found] = ON
#
#Wherein, a and b will represent the x and y of where you want the player is here
#image to show up on the world map scene.  And Z will only be turned on if you
#want to say the player has found a new location landmark which will show up on
#the world map scene.
#
#As you can see, this script is not noob friendly.  But it's not too complicated
#if you understand how to use the resources section and have a clear grasp of
#RPGMAKERVX mechanics.
#
#TO SUMMARIZE:   
# You need:
#       WORLD MAP IMAGE
#       CURRENT POSITION IMAGE
#       IMAGES FOR EVERY LANDMARK WHICH WILL APPEAR ON MAP ONCE FOUND
#       SWITCHES ACTIVATED WHEN SPECIFIC LANDMARKS ARE FOUND
#       PARALLEL EVENT on each map which either a)finds landmark,
#                                                b)changes player World Map position
#                                                c)does both
#                           
#
#Below are the two variables which will represent SCREEN X and SCREEN Y, while
#world map scene is displayed and will correspond to the current map the player
#is on as discussed above. 
#
WORLD_MAP_X = 3
WORLD_MAP_Y = 4
#
#  A VISUAL BREAKDOWN OF MECHANICS:
#
#        This is a WORLD MAP.  The player is represented by the 'x' this is
#determined in the script by displaying the 'x' at the location called for
#in the conditional branch.  Entering this position on the map has called a
#parallel event turning switch LANDMARK1 FOUND on.  When the player is
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#                 
#
#Now, Let's say the player travels north and into a map where a parallel event
#runs declaring the player has found a landmark (O) and changed position on the
#world map.  Four things have taken place.  Variable for MAP_ID, Variable for
#WORLD MAP X and Variable for WORLD MAP Y.  Also, the switch, LANDMARK (O)has
#been found (Be mindful that the O would show up behind the x in this scenario,
#showing that the new landmark has been found and that the player's there.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#Finally, we need to show what would happen if the player moved west from here
#onto a map which changed his WORLD MAP POSITION again.  As you can see, the
#player's location has changed once again on the map AND the O still appears
#because the new landmark was found.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   ! x ! O !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#END EDITTABLE REGION 1
#
#-------------------------------------------------------------------------------
#
  def self.world_map_data(id)
    image = ''
    landmark_x = 0
    landmark_y = 0
    found_switch = 0
    lm_index = 0
    lm_name = ''
    case id
#--------------------------------------------------------------------------------
#EDITTABLE REGION 2
#
#Here, you will tie a switch to an image.  Based on ID of switch in database and
#the name of an image in the resources of the project.  In the first part, when
#switch 2 is ON, the 'big town' image will be called and placed at screen x 25 and
#screen y 25, also the term 'TRAFFIC TOWN' will be displayed below the image.  The
#image will appear on viewport 2.
#
    when 1
      image = 'big town'  #name of image file for display on world map
      landmark_x = 25      #screen x of landmark as seen on world map
      landmark_y = 25       #screen y of landmark as seen on world map
      found_switch = 2      #switch which makes the image visible
      lm_index = 3          #viewport the image is shown on
      lm_name = 'Traffic Town'  #name of landmark shown below landmark image
    when 2
      image = 'small town'
      landmark_x = 50
      landmark_y = 25
      found_switch = 4
      lm_index = 4
      lm_name = 'Country Living'
    when 3
      image = 'forest'
      landmark_x = 75
      landmark_y = 25
      found_switch = 3
      lm_index = 5
      lm_name = 'Wooded Path'
#===============================================================================
#END EDITTABLE REGIONS
#===============================================================================
    end
    return image, landmark_x, landmark_y, found_switch, number
  end
 
 
  class Scene_Ix_World_Map < Scene_Base
    attr_accessor :id
    attr_accessor :image
    attr_accessor :landmark_x
    attr_accessor :landmark_y
    attr_accessor :found_switch
    attr_accessor :lm_index
    attr_accessor :lm_name
   
    def initialize
      @id = id
      @found_switch, @image, @landmark_x, @landmark_y, @found_switch, @number = Map_Script.data(id)
    end
   
    def create_mapback
      self.picture(1, WORLD_MAP_IMAGE)
    end
   
    def set_landmarks
      if $game_switches[Map_Script::id::found_switch]
        super()
        self.picture(lm_index, image)
        self.x = landmark_x
        self.y = landmark_y
        self.draw_text(lm_name, x - 20, y + 20)
      end
    end
   
    def set_player_position
      super()
      self.picture(20, CURRENT_POSITION)
      self.x = $game_variables[WORLD_MAP_X]
      self.y = $game_variables[WORLD_MAP_Y]
    end
  end
end

     
     

     

I haven't finished it.  Because I have a few questions.  What's the correct way to set up a check to see if a switch is on in a script?  Is this check a boolean?  Also, when asking for user input, when you want to check for Input.trigger? if the player is on the map, do you then have to create a new class as a subclass of scene_map?   

Anyway, I get an uninitialized constant error in the Game Interpreter when this scene is called via script on an map event.

Any help would be appreciated.  This could be a great and simple world map script.
     
 EDIT:   When I first started the script, I wanted to be able to use the integar beside the 'when' command (id) to signify a switch.  Instead, I need someway to iterate through the ids to test each for the switch is being on.  If it is possible to use the integars as switch ids, that would be useful information and make the script much simpler I imagine.
« Last Edit: July 15, 2011, 05:38:37 PM by IXFURU »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
You're already using the correct way to check a switch.

If you want to catch user input when on a map, alias Scene_Map's 'update' method. Just remember that any code placed in there gets updated about 60 times per second, so be careful.

I'm fairly certain that these two lines are choking your script up :

Code: [Select]
self.picture(20, CURRENT_POSITION)

self.picture(1, WORLD_MAP_IMAGE)

Use Map_Script::CURRENT_POSITION and so on to use your variables from the module.

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

***
Rep:
Level 75
What the...?
So, it would be:

Code: [Select]
self.picture(20, Map_Script::CURRENT_POSITION)

If so, that's the way I have it now.  If not, can you show me where I should put them and what if anything I should omit.

I'm still getting an unitialized constant NameError in the Game_Interpreter when it runs.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
To answer your questions,
$game_switches[ID] == true
Either alias update, or check for Input.press?, Input.trigger? or Input.repeat?
To check if the player is on a Scene_Map, just check
if $scene.is_a?(Scene_Map)
As for your uninitialized constant, I'd need to see the call and the error to tell you what's wrong.
it's like a metaphor or something i don't know

***
Rep:
Level 75
What the...?
The call is:

Code: [Select]
scene = $Scene_Ix_World_Map.new

Then the error is as follows:

NameError occured while running script
uninitialized constant Game_Interpreter::Scene_Ix_World_Map

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Oh, you don't need the dollar sign there, those are for specifying global variables.

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Yeah, it should be:

Code: [Select]
$scene = Scene_Ix_World_Map.new

but I suspect he knew that and must have mistyped or he wouldn't have gotten to the error he did.

Anyway, the main problem is that you put your scene class inside a module, so to call it you would need to do this:

Code: [Select]
$scene = Map_Script::Scene_Ix_World_Map.new

But why put it in module to begin with? Move it out.

***
Rep:
Level 75
What the...?
Thanks for the help.

When you say take it out, Modern, you are implying I should end the Module before beginning the scene class?  Is that right?  I tried that, thinking that's what you were saying.  But when I did, I immediately got an error at the last end of the script.  So, I removed it, and still got it.  Then I added one, and still got the error.   So if you could elaborate on that a little, please.

Also, I changed the call scene, by leaving the scene in the module and calling it as you stated in the previous post about having the :: signs to extract a scene from a module, and I get a NoMethodError at line 209

undefined method 'world_map_data' for
#<Map_Script::Scene_Ix_World_Map:0x2c8bea0 @id=nil>

The script has probably changed a little since I first posted it, so here's an update of how it looks right now:

Code: [Select]
#                     IXs_Map_Script 1.0
#                    By: IXFURU
# ----------------------------------------------------------------------------------
#You can use this script in any project you want.  Please give credit at some point
#in your project if you do.  If you use it for a commercial project, please contact
#me first.  webmaster@jibbes.com
#-----------------------------------------------------------------------------------
#
#
#
# This script will allow you to tie images to switches in your project.  Each
#switch will represent a map in your game.  Be sure to activate the switch using
#a parallel event when you enter a new map which will be marked on the map,
#using images.   If you plan on having more than 20 marked areas, it is imperative
#that you go retrieve some kind of limit break WHICH INCLUDES a limit break on
#the amount of pics one can have/display. 
#
#The script requires that you supply a WORLD_MAP_IMAGE which needs to be of a size
#which will act as a background when the world map scene is called. 
#
#IMPORTANT:  This script will also require you to add images for each visible
#landmark which will also appear on the map when it's appropriate switch is on.
#
#
#
##Another Thing:   
#You'll be using the first image (that is picture in viewport 1) to be the
#WORLD MAP and the 20th picture to be Player Position.  That said, if you don't
#have a limit breaker for pics, you'll only actually have 18 location images
#available to you at a single time, for that is the default amount of viewports.
#
#
#DONT MESS WITH THE module line
#---------------------------------------------------------------------------------
module Map_Script
#--------------------------------------------------------------------------------
#EDITTABLE REGION 1
#Here's where you set up the which map scene button which will call the World Map.
#Change the letter after the 'Input::' to whatever button you wish to call the Map.
#This button will both open AND close the scene.
#
WORLD_MAP_KEY = Input::R
#
#Next step is to set an image to be the background or main map when the World_Map
#Scene is called.  You'll have to supply the image in the image/pictures folder.
#
WORLD_MAP_IMAGE = "world map"
#
#Now, tie an image which will represent where you are currently on the map. Just
#replace the 'red dot' image with the name of an image fouund in the resources under
#pictures folder.
#
CURRENT_POSITION = "red dot"
#
#Lastly, you need to use two in-game variables to which needs to run be based
#on map_id.  This is done easily enough in the control variables section. These
#will be set below and will be set as WORLD MAP X and WORLD MAP Y.   Once again,
#you can set these variables each time a new map is visited.  Make a parallel
#event running out of reach of player character.  It will run whenever the
#player enters a map which changes his/her place on the WORLD MAP scene.
#
#
#It should look something like this:
#
#Control Variable[WORLD_MAP_X] = constant [a]
#Control Variable[WORLD_MAP_Y] = constant [b]
#Control Switches[z found] = ON
#
#Wherein, a and b will represent the x and y of where you want the player is here
#image to show up on the world map scene.  And Z will only be turned on if you
#want to say the player has found a new location landmark which will show up on
#the world map scene.
#
#As you can see, this script is not noob friendly.  But it's not too complicated
#if you understand how to use the resources section and have a clear grasp of
#RPGMAKERVX mechanics.
#
#TO SUMMARIZE:   
# You need:
#       WORLD MAP IMAGE
#       CURRENT POSITION IMAGE
#       IMAGES FOR EVERY LANDMARK WHICH WILL APPEAR ON MAP ONCE FOUND
#       SWITCHES ACTIVATED WHEN SPECIFIC LANDMARKS ARE FOUND
#       PARALLEL EVENT on each map which either a)finds landmark,
#                                                b)changes player World Map position
#                                                c)does both
#                           
#
#Below are the two variables which will represent SCREEN X and SCREEN Y, while
#world map scene is displayed and will correspond to the current map the player
#is on as discussed above. 
#
WORLD_MAP_X = 3
WORLD_MAP_Y = 4
#
#  A VISUAL BREAKDOWN OF MECHANICS:
#
#        This is a WORLD MAP.  The player is represented by the 'x' this is
#determined in the script by displaying the 'x' at the location called for
#in the conditional branch.  Entering this position on the map has called a
#parallel event turning switch LANDMARK1 FOUND on.  When the player is
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#                 
#
#Now, Let's say the player travels north and into a map where a parallel event
#runs declaring the player has found a landmark (O) and changed position on the
#world map.  Four things have taken place.  Variable for
#WORLD MAP X and Variable for WORLD MAP Y.  Also, the switch, LANDMARK (O)has
#been found (Be mindful that the O would show up behind the x in this scenario,
#showing that the new landmark has been found and that the player's there.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#Finally, we need to show what would happen if the player moved west from here
#onto a map which changed his WORLD MAP POSITION again.  As you can see, the
#player's location has changed once again on the map AND the O still appears
#because the new landmark was found.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   ! x ! O !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#END EDITTABLE REGION 1
#
#-------------------------------------------------------------------------------
#
  def self.world_map_data(id)
    image = ''
    landmark_x = 0
    landmark_y = 0
    found_switch = 0
    lm_index = 0
    lm_name = ''
    case id
#--------------------------------------------------------------------------------
#EDITTABLE REGION 2
#
#Here, you will tie a switch to an image.  Based on ID of switch in database and
#the name of an image in the resources of the project.  In the first part, when
#switch 2 is ON, the 'big town' image will be called and placed at screen x 25 and
#screen y 25, also the term 'TRAFFIC TOWN' will be displayed below the image.  The
#image will appear on viewport 2.
#
    when 1
      image = "big town"  #name of image file for display on world map
      landmark_x = 25      #screen x of landmark as seen on world map
      landmark_y = 25       #screen y of landmark as seen on world map
      found_switch = 2      #switch which makes the image visible
      lm_index = 3          #viewport the image is shown on
      lm_name = "Traffic Town"  #name of landmark shown below landmark image
    when 2
      image = "small town"
      landmark_x = 50
      landmark_y = 25
      found_switch = 4
      lm_index = 4
      lm_name = "Country Living"
    when 3
      image = "forest"
      landmark_x = 75
      landmark_y = 25
      found_switch = 3
      lm_index = 5
      lm_name = "Wooded Path"
#===============================================================================
#END EDITTABLE REGIONS
#===============================================================================
    end
    return image, landmark_x, landmark_y, found_switch, number
  end

 
 
  class Scene_Ix_World_Map < Scene_Base
    attr_accessor :id
    attr_accessor :image
    attr_accessor :landmark_x
    attr_accessor :landmark_y
    attr_accessor :found_switch
    attr_accessor :lm_index
    attr_accessor :lm_name
   
    def initialize
      @id = id
      @found_switch, @image, @landmark_x, @landmark_y, @found_switch, @number = world_map_data(id)
    end
   
    def create_mapback
      self.picture(1, Map_Script::WORLD_MAP_IMAGE)
    end
   
    def set_landmarks
      if $game_switches[Map_Script::id::found_switch]
        super()
        self.picture(lm_index, image)
        self.x = landmark_x
        self.y = landmark_y
        self.draw_text(lm_name, x - 20, y + 20)
      end
    end
   
    def set_player_position
      super()
      self.picture(1, Map_Script::CURRENT_POSITION)
      self.x = $game_variables[WORLD_MAP_X]
      self.y = $game_variables[WORLD_MAP_Y]
    end
  end
end

Line 209 is the line after the initialize method wherein I was trying to place several instance variables into a local array known as id.  Modern, I actually saw how you did something similar in your quest journal script, where you placed the variables of objectives into an array, (or maybe it was a hash), that could be called from the case and when part of the code. 

As I have stated earlier, I would have liked to see if it was possible to set up the 'when x' part of the script so that the x actually represented a switch that would be defined.  I feel like that would make it easier, as they would act more as if statements checking to see if these switches were on rather than having to iterate through each one of the whens based on id trying to find the found_switch variable and then  doing the correct modifications accordingly.  That way, the switch could act as both the id, and a variable in the same instance.  (Hope that makes sense:  It does in my head, for some reason :P).  At any rate, I couldn't find any scripts from which to study or verify that this could be done.  Not really sure I understand the process behind the case and when commands just yet.  But I'm working on it.

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Here is what MA means :

Code: [Select]
#                     IXs_Map_Script 1.0
#                    By: IXFURU
# ----------------------------------------------------------------------------------
#You can use this script in any project you want.  Please give credit at some point
#in your project if you do.  If you use it for a commercial project, please contact
#me first.  webmaster@jibbes.com
#-----------------------------------------------------------------------------------
#
#
#
# This script will allow you to tie images to switches in your project.  Each
#switch will represent a map in your game.  Be sure to activate the switch using
#a parallel event when you enter a new map which will be marked on the map,
#using images.   If you plan on having more than 20 marked areas, it is imperative
#that you go retrieve some kind of limit break WHICH INCLUDES a limit break on
#the amount of pics one can have/display. 
#
#The script requires that you supply a WORLD_MAP_IMAGE which needs to be of a size
#which will act as a background when the world map scene is called. 
#
#IMPORTANT:  This script will also require you to add images for each visible
#landmark which will also appear on the map when it's appropriate switch is on.
#
#
#
##Another Thing:   
#You'll be using the first image (that is picture in viewport 1) to be the
#WORLD MAP and the 20th picture to be Player Position.  That said, if you don't
#have a limit breaker for pics, you'll only actually have 18 location images
#available to you at a single time, for that is the default amount of viewports.
#
#
#DONT MESS WITH THE module line
#---------------------------------------------------------------------------------
module Map_Script
#--------------------------------------------------------------------------------
#EDITTABLE REGION 1
#Here's where you set up the which map scene button which will call the World Map.
#Change the letter after the 'Input::' to whatever button you wish to call the Map.
#This button will both open AND close the scene.
#
WORLD_MAP_KEY = Input::R
#
#Next step is to set an image to be the background or main map when the World_Map
#Scene is called.  You'll have to supply the image in the image/pictures folder.
#
WORLD_MAP_IMAGE = "world map"
#
#Now, tie an image which will represent where you are currently on the map. Just
#replace the 'red dot' image with the name of an image fouund in the resources under
#pictures folder.
#
CURRENT_POSITION = "red dot"
#
#Lastly, you need to use two in-game variables to which needs to run be based
#on map_id.  This is done easily enough in the control variables section. These
#will be set below and will be set as WORLD MAP X and WORLD MAP Y.   Once again,
#you can set these variables each time a new map is visited.  Make a parallel
#event running out of reach of player character.  It will run whenever the
#player enters a map which changes his/her place on the WORLD MAP scene.
#
#
#It should look something like this:
#
#Control Variable[WORLD_MAP_X] = constant [a]
#Control Variable[WORLD_MAP_Y] = constant [b]
#Control Switches[z found] = ON
#
#Wherein, a and b will represent the x and y of where you want the player is here
#image to show up on the world map scene.  And Z will only be turned on if you
#want to say the player has found a new location landmark which will show up on
#the world map scene.
#
#As you can see, this script is not noob friendly.  But it's not too complicated
#if you understand how to use the resources section and have a clear grasp of
#RPGMAKERVX mechanics.
#
#TO SUMMARIZE:   
# You need:
#       WORLD MAP IMAGE
#       CURRENT POSITION IMAGE
#       IMAGES FOR EVERY LANDMARK WHICH WILL APPEAR ON MAP ONCE FOUND
#       SWITCHES ACTIVATED WHEN SPECIFIC LANDMARKS ARE FOUND
#       PARALLEL EVENT on each map which either a)finds landmark,
#                                                b)changes player World Map position
#                                                c)does both
#                           
#
#Below are the two variables which will represent SCREEN X and SCREEN Y, while
#world map scene is displayed and will correspond to the current map the player
#is on as discussed above. 
#
WORLD_MAP_X = 3
WORLD_MAP_Y = 4
#
#  A VISUAL BREAKDOWN OF MECHANICS:
#
#        This is a WORLD MAP.  The player is represented by the 'x' this is
#determined in the script by displaying the 'x' at the location called for
#in the conditional branch.  Entering this position on the map has called a
#parallel event turning switch LANDMARK1 FOUND on.  When the player is
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#                 
#
#Now, Let's say the player travels north and into a map where a parallel event
#runs declaring the player has found a landmark (O) and changed position on the
#world map.  Four things have taken place.  Variable for
#WORLD MAP X and Variable for WORLD MAP Y.  Also, the switch, LANDMARK (O)has
#been found (Be mindful that the O would show up behind the x in this scenario,
#showing that the new landmark has been found and that the player's there.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   !   ! x !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#Finally, we need to show what would happen if the player moved west from here
#onto a map which changed his WORLD MAP POSITION again.  As you can see, the
#player's location has changed once again on the map AND the O still appears
#because the new landmark was found.
#
#                  __________________________
#                  !  !   !   !   !   !   !  !                       
#                  !-------------------------!
#                  !  !   !   ! x ! O !   !  !
#                  !-------------------------!
#                  !  !   !   !   !  !   !  !
#                  !-------------------------!
#                  !  !   !   !   !   !   !  !
#                  !_________________________!
#
#END EDITTABLE REGION 1
#
#-------------------------------------------------------------------------------
#
  def self.world_map_data(id)
    image = ''
    landmark_x = 0
    landmark_y = 0
    found_switch = 0
    lm_index = 0
    lm_name = ''
    case id
#--------------------------------------------------------------------------------
#EDITTABLE REGION 2
#
#Here, you will tie a switch to an image.  Based on ID of switch in database and
#the name of an image in the resources of the project.  In the first part, when
#switch 2 is ON, the 'big town' image will be called and placed at screen x 25 and
#screen y 25, also the term 'TRAFFIC TOWN' will be displayed below the image.  The
#image will appear on viewport 2.
#
    when 1
      image = "big town"  #name of image file for display on world map
      landmark_x = 25      #screen x of landmark as seen on world map
      landmark_y = 25       #screen y of landmark as seen on world map
      found_switch = 2      #switch which makes the image visible
      lm_index = 3          #viewport the image is shown on
      lm_name = "Traffic Town"  #name of landmark shown below landmark image
    when 2
      image = "small town"
      landmark_x = 50
      landmark_y = 25
      found_switch = 4
      lm_index = 4
      lm_name = "Country Living"
    when 3
      image = "forest"
      landmark_x = 75
      landmark_y = 25
      found_switch = 3
      lm_index = 5
      lm_name = "Wooded Path"
#===============================================================================
#END EDITTABLE REGIONS
#===============================================================================
    end
    return image, landmark_x, landmark_y, found_switch, number
  end
end
 
 
class Scene_Ix_World_Map < Scene_Base
  attr_accessor :id
  attr_accessor :image
  attr_accessor :landmark_x
  attr_accessor :landmark_y
  attr_accessor :found_switch
  attr_accessor :lm_index
  attr_accessor :lm_name
   
  def initialize
    @id = id
    @found_switch, @image, @landmark_x, @landmark_y, @found_switch, @number = Map_Script.world_map_data(id)
  end
   
  def create_mapback
    self.picture(1, Map_Script::WORLD_MAP_IMAGE)
  end
   
  def set_landmarks
    if $game_switches[Map_Script::id::found_switch]
      super()
      self.picture(lm_index, image)
      self.x = landmark_x
      self.y = landmark_y
      self.draw_text(lm_name, x - 20, y + 20)
    end
  end
   
  def set_player_position
    super()
    self.picture(1, Map_Script::CURRENT_POSITION)
    self.x = $game_variables[WORLD_MAP_X]
    self.y = $game_variables[WORLD_MAP_Y]
  end
end

Now you can call your scene by simply using : $scene = Scene_Ix_World_Map.new

However, now there is an issue on line 193, as the variable 'number' is not being set or initialized anywhere else within the 'world_map_data' method in your 'Map_Script' module.

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

***
Rep:
Level 75
What the...?
Thanks, Exhydra.

 I'm an idiot sometimes!  :( I was actually going to call the variable lm_index by the name number at first.  But then I thought it might cause problems with the pictures, as they have a variable called number already, which I believe corresponds to the viewport.  Anyway, when I changed it over, I must have forgotten to change that one over along with the others.

In positive news, it finally read through the script and sent me into the scene map when the call was created.

Now, that's about all the positive news.  As now I've got a black screen staring at me.  So, I'll just break this down and tell you what my thought process was behind the script, maybe that way, what I'm doing wrong will be more apparent.

After initialize, we go to a method called "create_map_back"
Here, I just want it to call the image from the module "WORLD_MAP_IMAGE"
I used self.picture because as far as I know, that's how you display a picture in script.  It calls for an array which includes (viewport, filename).  Therefor, I want the image to be displayed on viewport 1, so it is behind all the other pictures which will be displayed.  Then, i call "Map_Script::WORLD_MAP_IMAGE" because I wanted to retrieve the image from the module.  So, it looks like this.  Just one command.

Code: [Select]
def create_mapback   
self.picture(1, Map_Script::WORLD_MAP_IMAGE) 
end   

Next I go to the second part, which is where I want the scene to display the landmark images from the module.  This needs to iterate through the when parts of the world_map_data(id) searching each one for a switch which is on.  I thought I'd have problems with this one when I created it.  Because, I assumed that the statement 'if $game_switches[Map_Script::id::found_switch] would do the iterating for me.  After all, This statement says, look for a game switch whose id is found through the module Map_Script, in the id section, in the found_switch variable.   

That said, I had to create the appropriate images if the switch was on, so I created super(), saying I would be creating an array with the following variables and they would adopt all the information from the given class.  With self.picture(lm_index, image) I was trying to do just as I did in the first part, creating a picture by offering arguments of viewport and filename, in this situation, they would be found in the lm_index and image variables.  Once that was achieved, I utilized the self.x and self.y statements to tell the program I wanted the said picture set at x equal to the landmark_x variable and y to the landmark_y variable.    Once again, these are common picture functions.  Lastly, I want to display text near the landmark, so I use self.draw_text and follow it up with its arguments of (string variable, position x, and position y).  In this case, lm_name, x-20, y+20.

The code below shows my work for doing the paragraphs above:
Code: [Select]
  def set_landmarks     
if $game_switches[Map_Script::id::found_switch]     
super()     
self.picture(lm_index, image)     
self.x = landmark_x     
 self.y = landmark_y     
self.draw_text(lm_name, x - 20, y + 20)   
end 
end

Finally, I want to display the player's position.  I do this by using prinicples I've explained above.

Code: [Select]
def set_player_position   
super()   
self.picture(1, Map_Script::CURRENT_POSITION)   
self.x = $game_variables[WORLD_MAP_X]   
 self.y = $game_variables[WORLD_MAP_Y] 
end
end

So that's my thought process and how it would have conceivably worked.
« Last Edit: July 16, 2011, 04:51:11 AM by IXFURU »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Unfortunately, I'm not entirely on solid footing at this point, as I've never tried to display graphics or text within a Scene itself. I would imagine that creating custom window classes would be the easiest next step for you.

I happen to have a blank 'dummy window' class hanging around, so this might speed things along for you :

Code: [Select]
#==============================================================================
# ** Window_Dummy
#------------------------------------------------------------------------------
#  This is a multi-purpose window
#==============================================================================

class Window_Dummy < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def self.initialize(x, y, w, h, window_skin = "Window")
    super(x, y, w, WLH + h)
    self.windowskin = Cache.system(window_skin)
    refresh
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update

  end

  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh

  end
end

Your Scene would look something like this :

Code: [Select]
#==============================================================================
# ** Scene_Ix_World_Map
#==============================================================================

class Scene_Ix_World_Map < Scene_Base

  attr_accessor :id
  attr_accessor :image
  attr_accessor :landmark_x
  attr_accessor :landmark_y
  attr_accessor :found_switch
  attr_accessor :lm_index
  attr_accessor :lm_name

  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @id = id
    @found_switch, @image, @landmark_x, @landmark_y, @found_switch, @number = Map_Script.world_map_data(id)
  end
                                         
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_mapback
    @dummy_win = Window_Dummy.new (0, 0, 544, 416)
  end
 
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    @dummy_win.dispose
  end
 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @dummy_win.update
  end
 
  #--------------------------------------------------------------------------
  # * create_mapback
  #--------------------------------------------------------------------------
  def create_mapback
    self.picture(1, Map_Script::WORLD_MAP_IMAGE)
  end
             
  #--------------------------------------------------------------------------
  # * create_landmarks
  #--------------------------------------------------------------------------
  def set_landmarks
    if $game_switches[Map_Script::id::found_switch]
      super()
      self.picture(lm_index, image)
      self.x = landmark_x
      self.y = landmark_y
      self.draw_text(lm_name, x - 20, y + 20)
    end
  end
   
  #--------------------------------------------------------------------------
  # * set_player_position
  #--------------------------------------------------------------------------
  def set_player_position
    super()
    self.picture(1, Map_Script::CURRENT_POSITION)
    self.x = $game_variables[WORLD_MAP_X]
    self.y = $game_variables[WORLD_MAP_Y]
  end
 
end

I'm really not sure how best to display an image across the window, as I haven't tried it myself. I'm guessing updating the self.contents with a Bitmap.new(path\filename) ... but that might not work out. Perhaps using BitBlt or some such, I'm not sure. I'm not even certain that making a window is the best option for you.


EDIT: Ah, I guess since it's a new Scene you could just use 'pictures.show', now that I think about it. At any rate, this is new territory for me, so I'm unsure. Mm, but maybe not, as all of that would be through $game_map, which would not be present.
« Last Edit: July 16, 2011, 05:20:43 AM by Exhydra »

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

***
Rep:
Level 75
What the...?
So, basically, you're saying that I may have to write this in three different classes to get the scene to function properly.  I just watched some tutorials and read some stuff which could be related.  That seems to be where I have the hardest time in scripting.  Deciding which class to make my script a sub class of.  This is because, with picture, you have script sections in the Cache, in the Game_Picture, Sprite_Picture, and elsewhere.  That's where it confuses me.  If I want to bring up a picture, what arguments is it asking for?  In one section, perhaps the Game_Picture section, it suggests that it only requires one argument, that being the 'number' variable argument.  But this does little to distinguish in my mind, how one will be able to place the picture once its on the screen.  Nor, does it even give a direct way of calling it onto the screen.  There's load_bitmap, Sprite.new, self.picture.show, etc.  So, this gets really confusing for me sometimes. 

At any rate, I've been working on it more tonight while looking at other scripts and comparing the way they have them structured.  I also tried a different approach, wherein, I set up the module the same and then approached the body of the script in a different manner.   Yet, I'm not ready to let anyone see it just yet.   Maybe by morning.

EDIT:So, here's the new attempt at it:  I still have to write the dispose methods.  May need a little input there.


Code: [Select]
# IXs_Map_Script 1.0
# By: IXFURU
# ----------------------------------------------------------------------------------
#You can use this script in any project you want. Please give credit at some point
#in your project if you do. If you use it for a commercial project, please contact
#me first. webmaster@jibbes.com
#-----------------------------------------------------------------------------------
#
#
#
# This script will allow you to tie images to switches in your project. Each
#switch will represent a map in your game. Be sure to activate the switch using
#a parallel event when you enter a new map which will be marked on the map,
#using images. If you plan on having more than 20 marked areas, it is imperative
#that you go retrieve some kind of limit break WHICH INCLUDES a limit break on
#the amount of pics one can have/display.
#
#The script requires that you supply a WORLD_MAP_IMAGE which needs to be of a size
#which will act as a background when the world map scene is called.
#
#IMPORTANT: This script will also require you to add images for each visible
#landmark which will also appear on the map when it's appropriate switch is on.
#
#
#
##Another Thing:
#You'll be using the first image (that is picture in viewport 1) to be the
#WORLD MAP and the 20th picture to be Player Position. That said, if you don't
#have a limit breaker for pics, you'll only actually have 18 location images
#available to you at a single time, for that is the default amount of viewports.
#
#
#DONT MESS WITH THE module line
#---------------------------------------------------------------------------------
module Map_Script
#--------------------------------------------------------------------------------
#EDITTABLE REGION 1
#Here's where you set up the which map scene button which will call the World Map.
#Change the letter after the 'Input::' to whatever button you wish to call the Map.
#This button will both open AND close the scene.
#
WORLD_MAP_KEY = Input::R
#
#Next step is to set an image to be the background or main map when the World_Map
#Scene is called. You'll have to supply the image in the image/pictures folder.
#
WORLD_MAP_IMAGE = "world map"
#
#Now, tie an image which will represent where you are currently on the map. Just
#replace the 'red dot' image with the name of an image fouund in the resources under
#pictures folder.
#
CURRENT_POSITION = "red dot"
#
#Lastly, you need to use two in-game variables to which needs to run be based
#on map_id. This is done easily enough in the control variables section. These
#will be set below and will be set as WORLD MAP X and WORLD MAP Y. Once again,
#you can set these variables each time a new map is visited. Make a parallel
#event running out of reach of player character. It will run whenever the
#player enters a map which changes his/her place on the WORLD MAP scene.
#
#
#It should look something like this:
#
#Control Variable[WORLD_MAP_X] = constant [a]
#Control Variable[WORLD_MAP_Y] = constant [b]
#Control Switches[z found] = ON
#
#Wherein, a and b will represent the x and y of where you want the player is here
#image to show up on the world map scene. And Z will only be turned on if you
#want to say the player has found a new location landmark which will show up on
#the world map scene.
#
#As you can see, this script is not noob friendly. But it's not too complicated
#if you understand how to use the resources section and have a clear grasp of
#RPGMAKERVX mechanics.
#
#TO SUMMARIZE:
# You need:
# WORLD MAP IMAGE
# CURRENT POSITION IMAGE
# IMAGES FOR EVERY LANDMARK WHICH WILL APPEAR ON MAP ONCE FOUND
# SWITCHES ACTIVATED WHEN SPECIFIC LANDMARKS ARE FOUND
# PARALLEL EVENT on each map which either a)finds landmark,
# b)changes player World Map position
# c)does both
#
#
#Below are the two variables which will represent SCREEN X and SCREEN Y, while
#world map scene is displayed and will correspond to the current map the player
#is on as discussed above.
#
WORLD_MAP_X = 3
WORLD_MAP_Y = 4
#
# A VISUAL BREAKDOWN OF MECHANICS:
#
# This is a WORLD MAP. The player is represented by the 'x' this is
#determined in the script by displaying the 'x' at the location called for
#in the conditional branch. Entering this position on the map has called a
#parallel event turning switch LANDMARK1 FOUND on. When the player is
#
# __________________________
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! ! x ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !_________________________!
#
#
#
#Now, Let's say the player travels north and into a map where a parallel event
#runs declaring the player has found a landmark (O) and changed position on the
#world map. Four things have taken place. Variable for
#WORLD MAP X and Variable for WORLD MAP Y. Also, the switch, LANDMARK (O)has
#been found (Be mindful that the O would show up behind the x in this scenario,
#showing that the new landmark has been found and that the player's there.
#
# __________________________
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! ! x ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !_________________________!
#
#Finally, we need to show what would happen if the player moved west from here
#onto a map which changed his WORLD MAP POSITION again. As you can see, the
#player's location has changed once again on the map AND the O still appears
#because the new landmark was found.
#
# __________________________
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! x ! O ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !-------------------------!
# ! ! ! ! ! ! ! !
# !_________________________!
#
#END EDITTABLE REGION 1
#
#-------------------------------------------------------------------------------
#
  def self.world_map_data(id)
  image = ''
  landmark_x = 0
  landmark_y = 0
  found_switch = 0 
  lm_index = 0
  lm_name = ''
  case id
#--------------------------------------------------------------------------------
#EDITTABLE REGION 2
#
#Here, you will tie a switch to an image. Based on ID of switch in database and
#the name of an image in the resources of the project. In the first part, when
#switch 2 is ON, the 'big town' image will be called and placed at screen x 25 and
#screen y 25, also the term 'TRAFFIC TOWN' will be displayed below the image. The
#image will appear on viewport 2.
#
    when 1
      image = "big town" #name of image file for display on world map
      landmark_x = 25 #screen x of landmark as seen on world map
      landmark_y = 25 #screen y of landmark as seen on world map
      found_switch = 2 #switch which makes the image visible
      lm_index = 3 #viewport the image is shown on
      lm_name = "Traffic Town" #name of landmark shown below landmark image
    when 2
      image = "small town"
      landmark_x = 50
      landmark_y = 25
      found_switch = 4
      lm_index = 4
      lm_name = "Country Living"
    when 3
      image = "forest"
      landmark_x = 75
      landmark_y = 25
      found_switch = 3
      lm_index = 5
      lm_name = "Wooded Path"
#===============================================================================
#END EDITTABLE REGIONS
#===============================================================================
    end
  return image, landmark_x, landmark_y, found_switch, lm_index, lm_name
  end
end


class Scene_Ix_World_Map < Scene_Base

  attr_accessor :id
  attr_accessor :image
  attr_accessor :landmark_x
  attr_accessor :landmark_y
  attr_accessor :found_switch
  attr_accessor :lm_index
  attr_accessor :lm_name

#=======================================================================
#Create the Map
#======================================================================
  def create_map
    @world_map = picture.new
    @world_map = Cache.Pictures(Map_Script::WORLD_MAP_IMAGE)
    @world_map
    Picture.show(1, @world_map)
  end
 
#=========================================================================
#Create the Landmarks
#=========================================================================
  def create_landmarks
    if $game_switches[Map_Script.world_map_data::id::found_switch]
      return world_map_data(id)
      @image = Sprite.new
      @image = Cache.Pictures(Map_Script.world_map_data::id::image)
      @landmark_x = landmark_x(Map_Script.world_map_data::id::landmark_x)
      @landmark_y = landmark_y(Map_Script.world_map_data::id::landmark_y)
      @lm_name = lm_name(Map_Script.world_map_data::id::lm_name)
      @lm_index = lm_index(Map_Script.world_map_data::id::lm_index)
      @name_x = landmark_x - 20
      @name_y = landmark_y + 20
      self.picture.show(lm_index, @image, landmark_x, landmark_y)
      self.contents.draw_text(4, 0, @name_x, @name_y)
    else
      return
    end
  end
 
#================================================================================
#Create the Position of Player
#===============================================================================
  def create_position
    @position = Picture.new
    @position = Cache.Pictures(Map_Script::CURRENT_POSITION)
    @position_x = position_x(Map_Script::WORLD_MAP_X)
    @position_y = position_y(Map_Script::WORLD MAP Y)
    @position
    self.picture.show(20, Map_Script::CURRENT_POSITION, WORLD_MAP_X, WORLD_MAP_Y)
  end
 
#=================================================================== 
#Start Processing
#===================================================================
  def start
    super
    create_map
    create_landmarks
    create_position
  end
#===================================================================
#Termination
#====================================================================
  def terminate
    super
    dispose_map
    dispose landmarks
    dispose_position
    scene = $Scene_Map.new
  end

#====================================================================
#Update Processing
#======================================================================
  def update
    super
    #check for input
    if Input.trigger?(Map_Script::WORLD_MAP_KEY)
      Scene_Ix_Map.terminate
    else
    end
  end
end
« Last Edit: July 17, 2011, 12:03:57 PM by IXFURU »