Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Reload this Page [Question] Simple bank script

Notices
For all updates, view the main page.

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.



Reply
 
Thread Tools
  #1    
Old April 8th, 2013 (12:58 PM). Edited April 9th, 2013 by Black Eternity.
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 22
Gender: Male
Posts: 59
#This post has been edited since the script has been completed to my standards.
#Thanks to Maruno for help

The full script is here: http://www.pokecommunity.com/showthread.php?t=299771


This is the old post
Spoiler:
Okay so I'm working on adding a simple bank script for players to store extra money.
My problem is that I can't get the game to recognize my variable.
I can deposit money, but it does not add to the bank ($game_variables[014])
and I cannot withdraw, as I always get the "IF" statement since it does not update.

Can anyone help me with my script?
Code:
#This script is for storing the players money in a bank.

def pbDepositBank
  if $Trainer.money<MINDEPOSIT
    Kernel.pbMessage(
      _INTL("Sorry you must have at least ${1} to deposit.",MINDEPOSIT))
  else $Trainer.money>=MINDEPOSIT
    params=ChooseNumberParams.new
    params.setMaxDigits(6)
    params.setRange(MINDEPOSIT,$Trainer.money)
    params.setCancelValue(0)
    qty=Kernel.pbMessageChooseNumber(
      _INTL("How much would you like to deposit?"),params)
    $game_variables[014]=$game_variables[014]+qty
    $Trainer.money=$Trainer.money-qty
  end
end

def pbWithdrawBank
  if $game_variables[014]==0
      Kernel.pbMessage(
        _INTL("You do not have any money to withdraw"))
  else $game_variables[014]>=1
    params=ChooseNumberParams.new
    params.setMaxDigits(6)
    params.setRange(1,$game_variables[014])
    params.setCancelValue(0)
    qty=Kernel.pbMessage(
      _INTL("How much would you like to withdraw?"),params)
    $game_variables[014]=$game_variables[014]-qty
    $Trainer.money=$Trainer.money+qty
  end
end
Reply With Quote
  #2    
Old April 8th, 2013 (02:16 PM).
Maruno's Avatar
Maruno Maruno is online now
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 4,401
You put else rather than elsif. See if that works.
__________________
Reply With Quote
  #3    
Old April 8th, 2013 (02:20 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 22
Gender: Male
Posts: 59
Unfortunately I get the same result, even if I set $game_variables[014] to any number via the debug menu, the script does not recognize it.
__________________

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #4    
Old April 8th, 2013 (02:35 PM).
Maruno's Avatar
Maruno Maruno is online now
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 4,401
Where is MINDEPOSIT set?

In pbWithdrawBank, you need to use Kernel.pbMessageChooseNumber when choosing the number.
__________________
Reply With Quote
  #5    
Old April 8th, 2013 (02:57 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 22
Gender: Male
Posts: 59
MINDEPOSIT is set in script section "Settings"

Thanks, I see that I messed up in pbWithdrawBank with kernel.MessageChooseNumber
and had to change $game_variables[014] to 016 for the correct one to be used.

All works now.

Now i must ask, do you have any info on drawing a new moneybox? like pbDisplayCoinsWindow?
Reply With Quote
  #6    
Old April 8th, 2013 (03:04 PM).
Lord Varion's Avatar
Lord Varion Lord Varion is offline
Guess who's back?
 
Join Date: Feb 2009
Age: 20
Gender: Other
Nature: Naughty
Posts: 2,648
I've made a bank system using simple events;
If you want some help with it?


EDit: never mind, I see you've done it.
__________________
gone.
Reply With Quote
  #7    
Old April 8th, 2013 (04:23 PM).
Maruno's Avatar
Maruno Maruno is online now
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 4,401
Quote originally posted by Black Eternity:
Now i must ask, do you have any info on drawing a new moneybox? like pbDisplayCoinsWindow?
I figured things out when I created the coins window. The big thing to watch out for is making sure your new window won't overlap with either the money or coins window (if you want to show either/both of them at the same time) - if you're only ever going to show your window on its own, that makes things easier. I'm going to assume the easier case.

The script section PokemonMessages is what you want. Normally I wouldn't advise touching this, and even though the following instructions are fairly simple, I take no responsibility for any mucking-up that happens. In a nutshell, you're copying how the gold window works.

First, find def pbDisplayGoldWindow, copy-paste it and turn it into what you want.

Next, pick a letter or two to use to display your new window. For example, \G shows the money window, and \CN shows the coins window. Make sure it's not already being used by something else. Now find the longest line in that script section, which begins: while text[/(?:\\([WwFf]|[Ff][Ff]|... This line lists all the message commands available. A little over halfway into it is \\([Gg]|[Cc][Nn]|[Ww][Dd]|, and hopefully my colouring helps you see what's going on. Take your letter or two and put it straight after the coins part (including another vertical pipe to separate them). There's an example of a one-letter command and a two-letter command.

Now an easier part. A little further down, find the line which says: elsif control=="g". Copy-paste the three lines of this part and rename all the things accordingly. This includes goldwindow - call it something else, remember what you called it, and read the next paragraph.

Finally, there are two other lines to add in. Basically, find goldwindow=nil and goldwindow.dispose if goldwindow, and copy-paste them both and rename the things to what you chose in the previous paragraph.

Done!



My explanation could have been more eloquent. I'm tired.
__________________
Reply With Quote
  #8    
Old April 8th, 2013 (05:52 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 22
Gender: Male
Posts: 59
Thank you so much Maruno! I was able to get the bankwindow on the first try!
I greatly appreciate your help.
__________________

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
Reply
Quick Reply

Sponsored Links

You may also like.. (Beta)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 11:46 AM.