Okay, so I'm attempting to allow the player to choose an amount of items they wish to buy, with the amount stored into variable 16, and so this variable is supposed to set the price, multiplying the amount by the price, in this case, 10. Everything but this works, setting the price to the amount times 10, it just doesn't seem to do anything at all. I'm curious as to what I'm going wrong, because I'm new to Ruby scripting, so it's no surprise to me that I messed up, but I can't seem to figure out for the life of me what it is I did wrong; if anyone could help, that'd be amazing.[IMG]http://puu.sh/mV7CZ/b65e1b0e31.png[/IMG]
[IMG]http://puu.sh/mV7pC/f1ed9fa365.png[/IMG]
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
The error is in how you use variable 17. You have variable 17 is times variable 16 times 10, but since variable 17 is 0 (unless you changed it), you are doing 0 * the amount you are buying * 10, which will always be 0.
What you want is variable 17 is set to variable 16 * 10 (it will show as == in the event if you do that right), not times variable 16 * 10.
@Archeia: There's actually no scripting in the event the OP posted. You sure you want this in Script support?
bgillisp: Thanks, the moment you said that I was multiplying 17 by 16 by 10, I looked at the variable and realized I accidentally had multiply clicked instead of set, and immediately knew my mistake, thank you for explaining my issue in such an easy to understand way, even if it was an obvious problem lol
Yes, many people mistakenly talk about scripting when what they are really talking about is eventing. It just confuses everyone.
I've moved this thread to VX Ace Support. Please be sure to post your threads in the correct forum next time. Thank you.
Yeah Shaz, and as much as I hate to sound cocky, but I've been doing this since... I wanna say 2012 if not earlier, whenever it was that VX Ace came out, and so I've figured out eventing immensely well, so there are very few times that I can't solve a problem while eventing, but this one truly stumped me, assuming it was the scripting, just to find out I just wasn't paying attention to detail, though now I'm stumped again, now that I've fixed the variable issue, and now whenever I select "Yes" the game crashes and gives me the error "Script 'Game_Interpreter' line 374: Argument Error occurred. comparison of Fixnum with Array failed"[IMG]http://puu.sh/mVckf/12d155ce62.png[/IMG]
I'm having a bit of a hard time understanding your question but I feel like the probable cause of the error you're getting is that you typed [$game_variables[16]]*10 - in doing so, you created an array that holds the value of $game_variables[16] inside of it, then tried to multiply that array by 10 and compare it to a single-value variable (variable 18 Gold on Hand). Make sure to use the proper syntax $game_variables[16]*10 (note there's one less pair of brackets), or ($game_variables[16])*10 which will also evaluate properly.
Normally you'd do
Variable 17 = variable 16
Variable 17 *= 10
Or are you trying to learn scripting through this way?
*hugs*
- Zeriab