I am trying to define a constant in a script to an in-game variable. I am not accomplishing my task. Here's what I'm doing.
SAID_VARIABLE = $game_variables[1]
Can someone help? It needs to be defined by a game variable.
No. just no. Wont happen.
Constants are read before any of the runtime variables are set - this includes $game_variables. Due to this single fact ~ you will never be able to set a constant to the value of a game variable. (unless your constant is not defined at startup for some reason)
Also ~ why would you want to?
That will likely cause errors, there are many parts of code missing or incorrect from just that small part you have posted. 🙂
Also, you are attempting to set a constant to the value of a method before the method has been defined, this will also error. And the again, game_variables doesnt exist, so if you define the method beforehand, another error. 🙂
It didn't work. Do you have any ideas of how to impliment what I tried doing? Defining a method, then using that method to define a constant?
Well, your approach wont work for the reasons detailed above.
Also, there is no need for a constant to be set ~ you are not gaining anything by using a constant.
What exactly are you trying to achieve with your code, cause I honestly cannot tell from the code you have posted. Like umm, what is the desired result?
I want to grab a variable value, use that value to define a variable to grab, and then add 1 to that variable upon successful gathering, then display a message with the current variable value.
In order to use a variable to determine the id of another variable, you could do this...
$game_variables[$game_variables[1]]^ this would automatically contact the variable whos id is determined by the number stored within game variable 1.
In order to add 1 onto this variable, we could do this...
$game_variables[$game_variables[1]] += 1Finally, in order to show said variable within a message box, you should be able to do this within the text box (not tried, should work).
\V[\V[1]]So, putting that together with the code you showed previously you might end up with something like this... (not tried, might work)
VARIABLE_ID = 1 def gold_mining mine_success? ? successful_mine : failed_mine end def mine_success? rand(GOLD_RANGE) >= GOLD_SUCCESS end def successful_mine RPG::SE.new(MINE_SUCESS,MINE_SE_VOL,MINE_SE_PITCH).play $game_party.gain_item($data_items[GOLD_ITEM_ID],VALUE) $game_variables[$game_variables[VARIABLE_ID]] += 1 SceneManager.goto(Scene_Map) $game_message.add("Current node counter is \V[\V[#{VARIABLE_ID}]]") end def failed_mine SceneManager.goto(Scene_Map) end def dispose_main_viewport dispose_image_cover super endEdit:
Who wrote this script you are trying to alter, cause for lack of a better phase, its piss poor.
It worked! However, I needed to put two \'s in the messages in order for it to do the variable call through a game_message script call.
It was made by Reedo.
Never heard of that script writer.
Doesn't matter. The main thing is you got it working 😀
Yes! Thank to you! If I need more help, I will be sure to go to you. 😉
Do you have a chat program you use, or some way of contacting you directly through some means of real-time communication?
I might have need for a scripter for hire. 😉
Request sent on Steam.
Can you perhaps think of a better way to handle node gather count? So that I don't have to create tons of variables for each node?
There are at least 100+ nodes on just the first map, and I plan for there to be many maps.
Drafyr please do not double post, edit your previous post if you've got something to add.
Sorry, won't happen again.
what is the purpose of a 'node'?
To be a gatherable resource with a limited amount of resources.