Scripting Help?

Discussion in 'RPG Maker VX Ace' started by Tsuaja, Feb 4, 2016.

  1. Tsuaja

    Tsuaja Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    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]


    [​IMG]
     
    #1
  2. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,520
    Likes Received:
    14,150
    Location:
    Game Dev Salt Mines
    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.
     
    #2
  3. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,609
    Likes Received:
    11,599
    Location:
    USA
    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: Feb 4, 2016
    #3
  4. Tsuaja

    Tsuaja Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    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
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    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.
     
    #5
  6. Tsuaja

    Tsuaja Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    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] 
     
    Last edited by a moderator: Feb 4, 2016
    #6
  7. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    3,909
    Likes Received:
    3,278
    Location:
    Florida, USA
    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.
     
    #7
    Zeriab likes this.
  8. Zeriab

    Zeriab Huggins! Veteran

    Messages:
    1,198
    Likes Received:
    1,250
    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
     
    #8
  9. Tsuaja

    Tsuaja Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    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
     
    #9
  10. Andar

    Andar Veteran Veteran

    Messages:
    28,002
    Likes Received:
    6,327
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    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
     
    #10
  11. Tsuaja

    Tsuaja Villager Member

    Messages:
    5
    Likes Received:
    0
    First Language:
    English
    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
     
    #11

Share This Page