Use script call to identify map player is on

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have a common event which does player transfer things in a particular dungeon. That works fine. However, I want the event to do something slightly different if the player is on a particular map. Whereabouts the player is on that map is completely irrelevant, it is the map itself which is important.

Is there a script call I can use for a conditional branch?

Thanks
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
are you talking about the
$gameMap._mapId ? this give you the id from JSON (order map list, but break if you change order)
or also if you identify your map by name
$dataMap.displayName ?
or I may not be understood the question

PHP:
if($gameMap._mapId === myid){
 // do stuf
}
PHP:
if($dataMap.displayName === "dunjun2"){
 // do stuf
}
EDIT: sorry i not see you check for ruby code !
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Jonforum You gave me enough with the first option for me to translate it into Ruby, and it works.
So thank you!
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
Code:
class Game_Map
 def setup(map_id)
  super
  $map = self
 end
end
access from anywhere with $map.
no conditionals, nothing.
you can always drop the $map = self into the standard code itself, and it'll work the same
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
@Kes in a common event, you can use control variable : game data : map ID to load the map ID of the current map.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
don't need a script - the interpreter keeps the id of the current map. So you can use either $game_map.map_id or simply @map.id (or it may need to be self.map_id)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
So much simpler than I had thought. For some reason I'd got it into my head that the default map id option worked differently.

Thanks everyone for your help.

[mod]Closing[/mod]
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top