- Joined
- Jan 31, 2015
- Messages
- 53
- Reaction score
- 15
- First Language
- English
- Primarily Uses
I'm still new, sorry if this is a noob question... I've managed to get the outcome I want using a heap of variables, but I don't like it - It's too messy for me. (also, sorry if I haven't got all the terms correct)
The Short Version of this question is:
Can I use the MapID as a key in a Hash? or Bit Switch?
I want to use a Hash to store the state of something on a map.
Please bear with me, I've re-written this so many times trying to make sure I've made myself understandable.
To simplify what I'm speaking of, lets say I have 50 maps that are parts of a maze.
I am also trying to use a CommonEvent when I turn the lights on to save the state of the light (on or off)
Here's the 3 webpages I've been trying to learn from:
http://www.rpgmakervxace.net/topic/19191-hash-expressions/
http://ruby-doc.org/core-2.1.2/Array.html
https://himeworks.wordpress.com/2013/06/07/bit-switches/
I have found that I tend to make a mess, so before I start trying to make events, I try to write things out for myself in notepad to make sure my thoughts are in some kind of order, here's what I wrote for this process
If I have it right, I define the variable as a hash: MapLightState= {}
and when the player turns on the lights, I get the MapID into a variable with: Control Variables [0001:CurrentMap] = Map ID
and then set another variable with the current light state Control Variables [0002:CurrentLightState] = 1
And here is where I get stuck.
How can I pass the variables to be the contents of the hash?
How do I read the correct value back when the player enters a room?
I included the link above for Bit Switches - It looked promising and I was interested in using it as setting or calling a True/False value looked nice and easy: set_bit_switch(MapLightState, MapID, True)
I just hit the same issue of how to pass it the MapID of my current map, or the ID of a Map I want to change a state in.
The Short Version of this question is:
Can I use the MapID as a key in a Hash? or Bit Switch?
I want to use a Hash to store the state of something on a map.
Please bear with me, I've re-written this so many times trying to make sure I've made myself understandable.
To simplify what I'm speaking of, lets say I have 50 maps that are parts of a maze.
- Player is in Map3, they turn on the lights.
- Later, in Map6, they trigger the lights in Map3 to be turned off.
- When player enters Map3 again, I want the lights off.
I am also trying to use a CommonEvent when I turn the lights on to save the state of the light (on or off)
Here's the 3 webpages I've been trying to learn from:
http://www.rpgmakervxace.net/topic/19191-hash-expressions/
http://ruby-doc.org/core-2.1.2/Array.html
https://himeworks.wordpress.com/2013/06/07/bit-switches/
I have found that I tend to make a mess, so before I start trying to make events, I try to write things out for myself in notepad to make sure my thoughts are in some kind of order, here's what I wrote for this process
Define Variable: CurrentLightState (True or False)
Define Array: MapLightState
Array Name: MapLightState
Array Key: MapID
Array Value: State (True or False)
Player Turns on lights: (assuming lights off)
#SetLightsOn (commands to turn on the lights)
Get Current MapID
Set State to: True
Write to array: MapLightState(MapID,True)
Upon Player entering a room:
Get Current MapID
CurrentLightState = MapLightState(MapID,?value?)
If CurrentLightState = True #SetLightsOn
else #SetLightsOff
SetLightsOn
#Commands to turn on lights
SetLightsOff
#commands to turn lights off
Player Turns off the lights: (if the lights are on)
#SetLightsOff
Get Current MapID
Set State to: False
Write to array: MapLightState(MapID,False)
Repeate defining arrays to track other Map environment states: posioned air, dread, infestation
Define Array: MapLightState
Array Name: MapLightState
Array Key: MapID
Array Value: State (True or False)
Player Turns on lights: (assuming lights off)
#SetLightsOn (commands to turn on the lights)
Get Current MapID
Set State to: True
Write to array: MapLightState(MapID,True)
Upon Player entering a room:
Get Current MapID
CurrentLightState = MapLightState(MapID,?value?)
If CurrentLightState = True #SetLightsOn
else #SetLightsOff
SetLightsOn
#Commands to turn on lights
SetLightsOff
#commands to turn lights off
Player Turns off the lights: (if the lights are on)
#SetLightsOff
Get Current MapID
Set State to: False
Write to array: MapLightState(MapID,False)
Repeate defining arrays to track other Map environment states: posioned air, dread, infestation
If I have it right, I define the variable as a hash: MapLightState= {}
and when the player turns on the lights, I get the MapID into a variable with: Control Variables [0001:CurrentMap] = Map ID
and then set another variable with the current light state Control Variables [0002:CurrentLightState] = 1
And here is where I get stuck.
How can I pass the variables to be the contents of the hash?
How do I read the correct value back when the player enters a room?
I included the link above for Bit Switches - It looked promising and I was interested in using it as setting or calling a True/False value looked nice and easy: set_bit_switch(MapLightState, MapID, True)
I just hit the same issue of how to pass it the MapID of my current map, or the ID of a Map I want to change a state in.

