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,761
Reaction score
14,653
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
12,956
Reaction score
13,314
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,141
Reaction score
12,416
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
4,940
Reaction score
4,124
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,213
Reaction score
1,266
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,023
Reaction score
7,026
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

A while back I was having fun making my own custom tiles, then I hit carpet... why is it so difficult!? Lol.
Weekend is finally here... what would you like to see (?):
1) Pokemon into zelda minish-cap style
or
2) Pokemon into zelda gbc style
or
3) Zelda into pokemon style

#= Choose ===============#
||__[ Full mockup ]_[ Charset ]__||
#=======================#
I know someday I'll start working on this...

I'm so happy that I got Steam achievements to work in my game, thanks in large part to the posts by other RPG Maker devs on this issue!
Huzzah! My Tree of Life turned out pretty good!

Forum statistics

Threads
97,931
Messages
947,962
Members
129,173
Latest member
MugenLoop
Top