RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Using an in game variable in a script

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 75
What the...?
I am using Deriru's/Dairu's Simple Item Storage in order to create a second option, "Vault system", at a bank.  Here's how it works.

You approach the counter and the lady greets you, asking what you wish to do.  Either 1)take out a loan, 2)use vault system or 3)hear banking explanation.   If you choose two, she will then ask you how would you like to use the vault system.  Either place or remove items from vault, or you can choose to purchase more storage space.  If you choose to purchase more space, she then explains to you how much each space will cost depending upon your bank rating which is stored in a variable. (the higher it is, the less the spaces cost).  Then she asks you how many spaces you wish to purchase.   Immediately, the "number input" opens with two digits and is linked to a variable we'll call "X".  Once the number is entered, X becomes that number, and if you can afford it and there are a still that many spaces available (the max is 30) the bank lady grants your request and you are given X amount of extra storage spaces.

That sounds like it would be simple.  And really, it should be.  I have the formula all worked out.  However, I can't get the "Simple Item Storage" script to wok properly. 

There is a call script command for adding new storage space.   This command basically just opens the TOTAL amount of spaces that will be available.  In other words, you can't just say add X amount of spaces.  Instead, you have to add the X with the amount of spaces open before the transaction (a variable we'll call "Y") to get the new total amount (which we'll call "Z").   Then we have to place that number into the command:

Code: [Select]
$game_system.unlock_storages(amount)


So, the script is asking for an integar in the "amount" position.  Something I can't really give, because in my project, that integar can be a number of different values.  For example, if I have 7 currently available (y=7), and I purchase 4 (x=4), then that makes z=11, which will not always be the case.

Earlier today I tried this:
Quote
$game_system.unlock_storages($game_variable(74))

But that didn't work.  It returned an argument error.  0 for 1, or something to that effect.  I'm really just unsure as to how to use the correct syntax when calling variables with a script.  Was the way I wrote it correct?  Maybe not.

If someone could help, I'd greatly appreciate it.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
You were on the right track. Just change the $game_variable(74) parenthesis to brackets [].

EDIT: Lol yeah, it's $game_variables.
« Last Edit: September 19, 2010, 03:17:59 AM by cozziekuns »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
and $game_variables, not $game_variable. But yeah, use square brackets as cozziekuns says.

***
Rep:
Level 75
What the...?
Thanks for the help guys.

But it didn't work.

I'm wondering, if the script hasn't got the $game_variables included in the system itself, would that make it so it doesn't recognize the variable when used in place of an integer?  Like, I know there's differences between global, local and other type variables.  And I often see, (though I don't understand completely), how some folks begin their scripts by listing all the variables and classes and stuff that will be used in their script.  I don't know if that's the case here.  But I may just have to resort back to allowing the player to only buying 1 space at a time, or 3 spaces at a time.  That way, at least, the integer I add to the call script will be a constant one.

That sucks, though.  I hate compromising with the system.  I like to see my ideas fulfilled.


By the way, it works well with a simple integer.  I've tested it.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Well, it should work, unless there's a problem with the script. Are you sure your putting $game_system.unlock_storages($game_variables[74]) in the call command?

***
Rep:
Level 75
What the...?
Just double-checked it, cozziekuns, and that is affirmative.

$game_system.unlock_storages($game_variables[74])

That's a direct copy/paste.

However, it doesn't show up on one line in the script call.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Oh, then just do:

Code: [Select]
a = $game_variables[74]
$game_system.unlock_storages(a)

***
Rep:
Level 75
What the...?
So, it DOES have to fit on one line?

Cool. . .It works great, Cozziekuns.  Thanks for all the help.

This issue is resolved