Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Malfiros

Possible to make Event Local Variables?

Question

Hello!

I'm almost a complete "Noob" to RGSS/Ruby scripting but I am pretty good at using RMXP functions. I've come across a problem I can't seem to avoid. In any given event, each has Local Switches A, B, C, D. These switches are only used for that event, they do not effect other events, and can be turned on or off when within a called common event. I would like to use a simple script within any event to input the value of its Map Position to a set of variables that are used only by that specific event and all pages in the event in the same way that Local Switches are used. These local variables must also be able to be processed by the Interpreter for use in event conditional branches. Also, I'd like to input the event's sprite facing value (8 for facing up, 4 left, 6 right, 2 down) to a local variable. I then want to be able to " -= " the value of a Database Variable from any of these "Local Variables."

The main idea behind the code would look something like this:

 

Local Variable(facing) = This Event Direction

Local Variable(position_x) = This Event X Coords

Local Variable(position_y) = This Event Y Coords

Local Variable(position_x) -= $game_variables[0001]

Local Variable(position_y) -= $game_variables[0002]

 

Basically, I'm trying to make multiple monster events that each have their own unique map X and Y coords and a facing direction WITHOUT having to make 100+ variables in the database (and then have to modify my common events to accommodate for every one of these variables). My monster event coding has tons of conditional branches that call common events and are directly effected by the monsters' XY positions in relevance to the player's XY positions... like shooting a fireball or an arrow. The problem is that when I have multiple monsters that are all inputing their coords into a single set of database X and Y variables, one overwrites the other and in the end only one will work.

Like I said, I'm a Noob when it comes to scripting. I'm not sure how to make a local variable work in an event-based conditional branch nor how to input the value of map coords and event facing direction to the local variable. Any help out there? I'm sure that the answer is pretty simple for someone who knows scripting better than I do.

Edited by Malfiros

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Are you using some kind of custom battle system? Post a picture of the map and it might help me understand better.

Edited by rgangsta

Share this post


Link to post
Share on other sites
  • 0

I figured out enough scripting to accomplish what I wanted. The answer was to create a set of global arrays (ones with "$" at the beginning) for the X and Y coords. Each monster uses its own temporary variable, or an id tag, to assign its coords into the proper array index placement.

Edited by Malfiros

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...