Scripting Help?

Tsuaja

Villager
Member
Joined
Apr 13, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
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.



 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
14,882
Reaction score
15,048
First Language
Filipino
Primarily Uses
VNM
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,114
Reaction score
13,614
First Language
English
Primarily Uses
RMVXA
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?
 
Last edited by a moderator:

Tsuaja

Villager
Member
Joined
Apr 13, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,367
Reaction score
12,876
First Language
English
Primarily Uses
RMMV
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.
 

Tsuaja

Villager
Member
Joined
Apr 13, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
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"
 
 
Last edited by a moderator:

Wavelength

Edge of Eternity
Global Mod
Joined
Jul 22, 2014
Messages
5,144
Reaction score
4,456
First Language
English
Primarily Uses
RMVXA
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.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,228
Reaction score
1,304
First Language
English
Primarily Uses
RMXP
Normally you'd do


Variable 17 = variable 16


Variable 17 *= 10


Or are you trying to learn scripting through this way?


*hugs*


 - Zeriab
 

Tsuaja

Villager
Member
Joined
Apr 13, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Normally you'd do


Variable 17 = variable 16


Variable 17 *= 10


Or are you trying to learn scripting through this way?


*hugs*


 - Zeriab
That's the problem, I don't know lol but I haven't tried it yet, but I'm assuming Wavelength's solution will probably fix my problem, I'm gonna see when I get home later today
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,261
Reaction score
7,138
First Language
German
Primarily Uses
RMMV
That's the problem, I don't know lol but I haven't tried it yet, but I'm assuming Wavelength's solution will probably fix my problem, I'm gonna see when I get home later today
DO NOT use the script option unless you know exactly what you want to do - it is completely unneccessary for your solution, see attached picture to see your main mistake


I also suggest you follow the link to the starting point in my signature and work through the tutorials listed there, especially the "Variables Guide"

controlvar.png
 

Tsuaja

Villager
Member
Joined
Apr 13, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
DO NOT use the script option unless you know exactly what you want to do - it is completely unneccessary for your solution, see attached picture to see your main mistake


I also suggest you follow the link to the starting point in my signature and work through the tutorials listed there, especially the "Variables Guide"


View attachment 30933
Yeah the worst part is after you said scripting was unnecessary, I immediately thought of an easier way to fix my issue than any of this that didn't include scripting lol
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Remember, you can enter up to THREE effects for a chance to win a copy of MZ! Only 11 submissions so far, the chances of winning is high! :D https://itch.io/jam/elfkisser
wake me up when Photoshop stop crashing everytime
Brioche with a crème patissiere filling is so tasty!
A group of Game creators and others who trying to revive the Feel of Multiplayer and TOWN/ROLEPLAY games
Wow, lots of RPG Maker MV stuff on sale on Steam for 50%-75% off. Steam, why you not tell me?!

Forum statistics

Threads
99,385
Messages
964,687
Members
131,008
Latest member
hotelbones
Top