nerthul11

Warper
Member
Joined
Jan 20, 2021
Messages
4
Reaction score
1
First Language
Spanish
Primarily Uses
RMXP
I'm looking for a way to set a variable's value to the event's map ID through a script so I can call a function passing the event's ID as a parameter. I was thinking of something like $game_map.events[self].id, but when calling "self" from an event, I'm not getting what I'm looking for. I've found a few references of this problem for other engines (MV or Ace) but not for XP.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
403
Reaction score
179
First Language
PT-BR
Primarily Uses
RM2k3
Try:
Ruby:
@event_id

Example using variable 19:
Ruby:
$game_variables[19]=@event_id

I hope that's it, good luck.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,131
Reaction score
14,643
First Language
English
Primarily Uses
RMMV
uh ... Control Variables > Other > Map ID

Do you want the map id or the event id? You said one, then you said the other.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,034
Reaction score
678
First Language
English
Primarily Uses
RMVXA
$game_map.events[self].id
Try:
Ruby:
@event_id
Tested and correct. same as with VX Ace.
Ruby:
$game_map.events[@event_id].id
BUT,
XP doesn't have a script function for the variables so you just need to do a full script command in the window to the variable you are using
Ruby:
$game_variables[5] =
$game_map.events[@event_id].id
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
403
Reaction score
179
First Language
PT-BR
Primarily Uses
RM2k3
@Roninator2
The command to call script from Rpgxp has line auto wrapping. That is why writing such a long command does not work.
As I understand it, this is totally redundant:
Ruby:
@event_id //return whole number
$game_map.events[@event_id].id //return whole number

I'm sorry if I got it wrong.
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
403
Reaction score
179
First Language
PT-BR
Primarily Uses
RM2k3
Really, I didn't know that the line break would be ignored if I did it that way.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,034
Reaction score
678
First Language
English
Primarily Uses
RMVXA
the line break would be ignored
It's one of the tings I learned with ruby. I think it was part of my class, but it was probable somebody on here. Code can be broken after operations. == && ||
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,131
Reaction score
14,643
First Language
English
Primarily Uses
RMMV
A like break will work if you make it clear that there is more to come. You can end a line with any of these:
( [ { = + - / * %
and probably a few others, and it will look for the remainder of the command on the next line (and on the one after, if you end that line the same way)

So this will work:
Code:
$game_variables[5] =
$game_map.events[@event_id].id

but this will not:
Code:
$game_variables[5]
= $game_map.events[@event_id].id

Now, on the question at hand, why not just do this?
Code:
$game_variables[5] = @event_id

It kind of seems redundant to use the @event_id variable to look up the event from the map just to get its event id ... you already have the event id - that's what you're using to look up the event to get the id from ;)
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,293
Reaction score
1,471
First Language
English
Primarily Uses
RMXP
If you want to understand how line brakes are handled in a deeper sense I recommend inspecting the Ruby grammar.
Here are a couple of links to a BNF specification:

Look at then TERM is used and not used.
You can use this knowledge to parse when the newline will have an affect on what you are trying to do.
If learning how to interpret a BNF seems too daunting you can just try splitting the line at different places and see how they work.
 

nerthul11

Warper
Member
Joined
Jan 20, 2021
Messages
4
Reaction score
1
First Language
Spanish
Primarily Uses
RMXP
uh ... Control Variables > Other > Map ID

Do you want the map id or the event id? You said one, then you said the other.
I was asking for event id

All your answers proved useful, thanks a lot!
 

Latest Threads

Latest Posts

Latest Profile Posts

dd_airport2.jpgdd_combat.jpg
dd_town.jpg
I did an experiment to try to solve the art style problem between RTP and 3D models.
But, it feels this grimdark world is going to end even faster. :kaoswt2:
Solovei wrote on caethyril's profile.
Hi, just wanted to say, thank you for helping me fix that event with the step count! I followed your example exactly and it works now:kaojoy:
still waiting for original character contest 3 bust/face dlc release :kaoluv:
Stimpaks and More.png
Continued work. Still a WIP, some need some retouching. Stimpak, Radaway, Psycho, Jet, Mentats, Medex(ish/needs to be purple), bloodpack, glowing bloodpack. Made some Nuka too. Need to make Rad-X.
Nuka Sheet WIP FR.png
Done translating our projects intro sequence : D

Forum statistics

Threads
111,183
Messages
1,059,060
Members
144,427
Latest member
AzureDragonSoul
Top