Go Back   The PokéCommunity Forums > Create & Discover > Game Development > Pokémon Essentials
Reload this Page buying things with coins

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 June 22nd, 2012 (5:07 PM).
p.claydon p.claydon is offline
 
Join Date: Jan 2011
Gender:
Posts: 323

ok i want to make use of coins other than to play minigames such as to buy items or pokemon how can this be done or would it have to be done via choice boxes (long choice boxes)

Reply With Quote

Relevant Advertising!

  #2    
Old June 22nd, 2012 (5:46 PM).
Nickalooose Nickalooose is offline
--------------------
 
Join Date: Mar 2008
Gender: Female
Posts: 1,285

Well what do you want them to do? Items and Pokémon is everything...

Reply With Quote
  #3    
Old June 23rd, 2012 (2:46 AM).
p.claydon p.claydon is offline
 
Join Date: Jan 2011
Gender:
Posts: 323

well like the gamecorner from red and blue were you could buy very rare pokemon such as porygon and TMs (altho i could have dreamt it as its been sooo long since played those) although i would be happy with just being able to buy v rare pokemon with them

Reply With Quote
  #4    
Old June 23rd, 2012 (8:17 AM).
Nickalooose Nickalooose is offline
--------------------
 
Join Date: Mar 2008
Gender: Female
Posts: 1,285

I'm pretty sure that already exists... It would be done by using Conditional Branches, checking how much is in the coin case, and comparing it to the Pokémon/TM you are buying, so yeah, it would be done VIA long conditional branches, then using pbAddPokemon(PBSPecies::PORYGON,20) to the branch that allows the buying of a Pokémon, then use the script to reduce the amount of coins owned by how much the Pokémon is worth and same for TM's.

For each different branch you will want a check, the only other thing you could use is 1 check at the beggining of the event to check how much is owned, then show choices depending on the players coins... You will probably want to use <= and >= if it's this route you take, and not specifics like ==.

I have a lot of ideas for this, but with the basics, you can use your imagination, or just keep it like it is (there is nothing wrong with the way it is now or the way it was then).

I would however, use the Essentials built in choices menu as that can hold more than 4 choices, so the list of Pokémon you can buy will be endless, so to speak.

I can't give you the code for the coin case because I don't use this in my game, but, I'm pretty sure it should either be on the Wiki or part of the Essentials untouched kit.

Good luck and let us know how it turns out or if you need more help.

Reply With Quote
  #5    
Old June 24th, 2012 (8:50 AM). Edited June 25th, 2012 by p.claydon.
p.claydon p.claydon is offline
 
Join Date: Jan 2011
Gender:
Posts: 323

ok thank you for the help managed to get something working

EDIT
ok for those who wish to use the script im using for my game corner shop here it is

Code:
def pbcoinvalue
  $game_variables[32]=$PokemonGlobal.coins
  $game_variables[31]=$Trainer.money
  $Trainer.money=$game_variables[32]
end

def pbgoldvalue $game_variables[32]=$Trainer.money $Trainer.money=$game_variables[31] $PokemonGlobal.coins=$game_variables[32] end

class GameCornerScene def update pbUpdateSpriteHash(@sprites) @subscene.update if @subscene end

def pbChooseNumber(helptext,item,maximum) curnumber=1 ret=0 [email protected]["helpwindow"] [email protected](item) itemprice/=2 if [email protected] pbDisplay(helptext,true) using(numwindow=Window_AdvancedTextPokemon.new("")){ # Showing number of items [email protected](item) using(inbagwindow=Window_AdvancedTextPokemon.new("")){ # Showing quantity in bag pbPrepareWindow(numwindow) pbPrepareWindow(inbagwindow) [email protected] numwindow.width=224 numwindow.height=64 numwindow.baseColor=Color.new(88,88,80) numwindow.shadowColor=Color.new(168,184,184) [email protected] [email protected] inbagwindow.width=190 inbagwindow.height=64 inbagwindow.baseColor=Color.new(88,88,80) inbagwindow.shadowColor=Color.new(168,184,184) inbagwindow.text=_ISPRINTF("In Bag:<r>{1:d} ",qty) numwindow.text=_ISPRINTF("x{1:d}<r>$ {2:d}",curnumber,curnumber*itemprice) pbBottomRight(numwindow) numwindow.y-=helpwindow.height pbBottomLeft(inbagwindow) inbagwindow.y-=helpwindow.height loop do Graphics.update Input.update numwindow.update inbagwindow.update self.update if Input.repeat?(Input::LEFT) pbPlayCursorSE() curnumber-=10 curnumber=1 if curnumber<1 numwindow.text=_ISPRINTF("x{1:d}<r>$ {2:d}",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::RIGHT) pbPlayCursorSE() curnumber+=10 curnumber=maximum if curnumber>maximum numwindow.text=_ISPRINTF("x{1:d}<r>$ {2:d}",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::UP) pbPlayCursorSE() curnumber+=1 curnumber=1 if curnumber>maximum numwindow.text=_ISPRINTF("x{1:d}<r>$ {2:d}",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::DOWN) pbPlayCursorSE() curnumber-=1 curnumber=maximum if curnumber<1 numwindow.text=_ISPRINTF("x{1:d}<r>$ {2:d}",curnumber,curnumber*itemprice) elsif Input.trigger?(Input::C) pbPlayDecisionSE() ret=curnumber break elsif Input.trigger?(Input::B) pbPlayCancelSE() ret=0 break end end } } helpwindow.visible=false return ret end

def pbPrepareWindow(window) window.visible=true window.letterbyletter=false end

def pbStartBuyOrSellScene(buying,stock,adapter) # Scroll right before showing screen pbScrollMap(6,5,5) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @stock=stock @adapter=adapter @sprites={} @sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"].setBitmap("Graphics/Pictures/martScreen") @sprites["icon"]=IconSprite.new(12,Graphics.height-74,@viewport) winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter) @sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter, Graphics.width-316-16,12,330+16,Graphics.height-126) @sprites["itemwindow"].[email protected] @sprites["itemwindow"].index=0 @sprites["itemwindow"].refresh @sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("") pbPrepareWindow(@sprites["itemtextwindow"]) @sprites["itemtextwindow"].x=64 @sprites["itemtextwindow"].y=Graphics.height-96-16 @sprites["itemtextwindow"].width=Graphics.width-64 @sprites["itemtextwindow"].height=128 @sprites["itemtextwindow"].baseColor=Color.new(248,248,248) @sprites["itemtextwindow"].shadowColor=Color.new(0,0,0) @sprites["itemtextwindow"].visible=true @sprites["itemtextwindow"].[email protected] @sprites["itemtextwindow"].windowskin=nil @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["helpwindow"]) @sprites["helpwindow"].visible=false @sprites["helpwindow"].[email protected] pbBottomLeftLines(@sprites["helpwindow"],1) @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["moneywindow"]) @sprites["moneywindow"].visible=true @sprites["moneywindow"].[email protected] @sprites["moneywindow"].x=0 @sprites["moneywindow"].y=0 @sprites["moneywindow"].width=190 @sprites["moneywindow"].height=96 @sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].shadowColor=Color.new(168,184,184) pbDeactivateWindows(@sprites) @buying=buying pbRefresh Graphics.frame_reset end

def pbStartBuyScene(stock,adapter) pbStartBuyOrSellScene(true,stock,adapter) end

def pbStartSellScene(bag,adapter) if $PokemonBag pbStartSellScene2(bag,adapter) else pbStartBuyOrSellScene(false,bag,adapter) end end

def pbStartSellScene2(bag,adapter) @subscene=PokemonBag_Scene.new @adapter=adapter @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport2.z=99999 for j in 0..17 col=Color.new(0,0,0,j*15) @viewport2.color=col Graphics.update Input.update end @subscene.pbStartScene(bag) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @sprites={} @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["helpwindow"]) @sprites["helpwindow"].visible=false @sprites["helpwindow"].[email protected] pbBottomLeftLines(@sprites["helpwindow"],1) @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["moneywindow"]) @sprites["moneywindow"].visible=false @sprites["moneywindow"].[email protected] @sprites["moneywindow"].x=0 @sprites["moneywindow"].y=0 @sprites["moneywindow"].width=186 @sprites["moneywindow"].height=96 @sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].shadowColor=Color.new(168,184,184) pbDeactivateWindows(@sprites) @buying=false pbRefresh end

def pbShowMoney pbRefresh @sprites["moneywindow"].visible=true end

def pbHideMoney pbRefresh @sprites["moneywindow"].visible=false end

def pbEndBuyScene pbDisposeSpriteHash(@sprites) @viewport.dispose # Scroll left after showing screen pbScrollMap(4,5,5) end

def pbEndSellScene if @subscene @subscene.pbEndScene end pbDisposeSpriteHash(@sprites) if @viewport2 for j in 0..17 col=Color.new(0,0,0,(17-j)*15) @viewport2.color=col Graphics.update Input.update end @viewport2.dispose end @viewport.dispose if [email protected] pbScrollMap(4,5,5) end end

def pbDisplay(msg,brief=false) [email protected]["helpwindow"] cw.letterbyletter=true cw.text=msg pbBottomLeftLines(cw,2) cw.visible=true i=0 pbPlayDecisionSE() loop do Graphics.update Input.update self.update if brief && !cw.busy? return end if i==0 && !cw.busy? pbRefresh end if Input.trigger?(Input::C) && cw.busy? cw.resume end if i==60 return end i+=1 if !cw.busy? end end

def pbDisplayPaused(msg) [email protected]["helpwindow"] cw.letterbyletter=true cw.text=msg pbBottomLeftLines(cw,2) cw.visible=true i=0 pbPlayDecisionSE() loop do Graphics.update Input.update wasbusy=cw.busy? self.update if !cw.busy? && wasbusy pbRefresh end if Input.trigger?(Input::C) && cw.resume && !cw.busy? @sprites["helpwindow"].visible=false return end end end

def pbConfirm(msg) [email protected]["helpwindow"] dw.letterbyletter=true dw.text=msg dw.visible=true pbBottomLeftLines(dw,2) commands=[_INTL("Yes"),_INTL("No")] cw = Window_CommandPokemon.new(commands) [email protected] pbBottomRight(cw) cw.y-=dw.height cw.index=0 pbPlayDecisionSE() loop do cw.visible=!dw.busy? Graphics.update Input.update cw.update self.update if Input.trigger?(Input::B) && dw.resume && !dw.busy? cw.dispose @sprites["helpwindow"].visible=false return false end if Input.trigger?(Input::C) && dw.resume && !dw.busy? cw.dispose @sprites["helpwindow"].visible=false return (cw.index==0)?true:false end end end

def pbRefresh if [email protected] [email protected]["itemwindow"] [email protected](itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["icon"].[email protected](itemwindow.item) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @adapter.getDescription(itemwindow.item) itemwindow.refresh end @sprites["moneywindow"].text=_INTL("Coins\n<r>$ {1}",@adapter.getMoney()) end

def pbChooseBuyItem [email protected]["itemwindow"] @sprites["helpwindow"].visible=false pbActivateWindow(@sprites,"itemwindow"){ pbRefresh loop do Graphics.update Input.update olditem=itemwindow.item self.update if itemwindow.item!=olditem [email protected](itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["icon"].[email protected](itemwindow.item) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @adapter.getDescription(itemwindow.item) end if Input.trigger?(Input::B) return 0 end if Input.trigger?(Input::C) if itemwindow.index<@stock.length pbRefresh return @stock[itemwindow.index] else return 0 end end end } end

def pbChooseSellItem if @subscene return @subscene.pbChooseItem else return pbChooseBuyItem end end end

def pbgamecorner(stock,speech=nil,cantsell=false) pbcoinvalue for i in 0...stock.length if pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0 stock[i]=nil end end stock.compact! commands=[] cmdBuy=-1 cmdQuit=-1 commands[cmdBuy=commands.length]=_INTL("Buy") commands[cmdQuit=commands.length]=_INTL("Quit") cmd=Kernel.pbMessage( speech ? speech : _INTL("Welcome!\r\nHow may I serve you?"), commands,cmdQuit+1) loop do if cmdBuy>=0 && cmd==cmdBuy scene=GameCornerScene.new screen=PokemonMartScreen.new(scene,stock) screen.pbBuyScreen else Kernel.pbMessage(_INTL("Please come again!")) break end cmd=Kernel.pbMessage( _INTL("Is there anything else I can help you with?"),commands,cmdQuit+1) end pbgoldvalue end

its used excatly like a pokemart shop except it uses your coins rather than your money/pokédollars

to use just do a script call like this

Code:
pbgamecorner([
PBItems::POKEBALL,
PBItems::POTION,
PBItems::ANTIDOTE,])

Reply With Quote
  #6    
Old January 26th, 2014 (4:40 AM). Edited January 26th, 2014 by p.claydon.
p.claydon p.claydon is offline
 
Join Date: Jan 2011
Gender:
Posts: 323

ok so this script still works but i just want to do a slight update which is to remove $ and add coins to the price list (already figured out how to do the change everywere else)

Edit
ok fixed no issues now (so far)

updated script

Code:
def pbcoinvalue
  $game_variables[32]=$PokemonGlobal.coins
  $game_variables[31]=$Trainer.money
  $Trainer.money=$game_variables[32]
end

def pbgoldvalue $game_variables[32]=$Trainer.money $Trainer.money=$game_variables[31] $PokemonGlobal.coins=$game_variables[32] end

class PokemonMartCoinsAdapter def getMoney return $Trainer.money end

def setMoney(value) $Trainer.money=value end

def getInventory() return $PokemonBag end

def getPrice(item) return $ItemData[item][ITEMPRICE] end

def getItemIcon(item) return nil if !item return pbItemIconFile(item) end

def getItemIconRect(item) return Rect.new(0,0,48,48) end

def getDisplayName(item) itemname=PBItems.getName(item) if pbIsMachine?(item) machine=$ItemData[item][ITEMMACHINE] itemname=_INTL("{1} {2}",itemname,PBMoves.getName(machine)) end return itemname end

def getName(item) return PBItems.getName(item) end

def getDisplayPrice(item) price=getPrice(item) return _ISPRINTF("{1:d} Coins",price) end

def getDescription(item) return pbGetMessage(MessageTypes::ItemDescriptions,item) end

def addItem(item) return $PokemonBag.pbStoreItem(item) end

def getQuantity(item) return $PokemonBag.pbQuantity(item) end

def canSell?(item) return getPrice(item)>0 && !pbIsImportantItem?(item) end

def showQuantity?(item) return !pbIsImportantItem?(item) end

def removeItem(item) return $PokemonBag.pbDeleteItem(item) end end

class GameCornerScene def update pbUpdateSpriteHash(@sprites) @subscene.update if @subscene end

def pbChooseNumber(helptext,item,maximum) curnumber=1 ret=0 [email protected]["helpwindow"] [email protected](item) itemprice/=2 if [email protected] pbDisplay(helptext,true) using(numwindow=Window_AdvancedTextPokemon.new("")){ # Showing number of items [email protected](item) using(inbagwindow=Window_AdvancedTextPokemon.new("")){ # Showing quantity in bag pbPrepareWindow(numwindow) pbPrepareWindow(inbagwindow) [email protected] numwindow.width=224 numwindow.height=64 numwindow.baseColor=Color.new(88,88,80) numwindow.shadowColor=Color.new(168,184,184) [email protected] [email protected] inbagwindow.width=190 inbagwindow.height=64 inbagwindow.baseColor=Color.new(88,88,80) inbagwindow.shadowColor=Color.new(168,184,184) inbagwindow.text=_ISPRINTF("In Bag:<r>{1:d} ",qty) numwindow.text=_ISPRINTF("x{1:d} {2:d} Coins",curnumber,curnumber*itemprice) pbBottomRight(numwindow) numwindow.y-=helpwindow.height pbBottomLeft(inbagwindow) inbagwindow.y-=helpwindow.height loop do Graphics.update Input.update numwindow.update inbagwindow.update self.update if Input.repeat?(Input::LEFT) pbPlayCursorSE() curnumber-=10 curnumber=1 if curnumber<1 numwindow.text=_ISPRINTF("x{1:d} {2:d} Coins",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::RIGHT) pbPlayCursorSE() curnumber+=10 curnumber=maximum if curnumber>maximum numwindow.text=_ISPRINTF("x{1:d} {2:d} Coins",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::UP) pbPlayCursorSE() curnumber+=1 curnumber=1 if curnumber>maximum numwindow.text=_ISPRINTF("x{1:d} {2:d} Coins",curnumber,curnumber*itemprice) elsif Input.repeat?(Input::DOWN) pbPlayCursorSE() curnumber-=1 curnumber=maximum if curnumber<1 numwindow.text=_ISPRINTF("x{1:d} {2:d} Coins",curnumber,curnumber*itemprice) elsif Input.trigger?(Input::C) pbPlayDecisionSE() ret=curnumber break elsif Input.trigger?(Input::B) pbPlayCancelSE() ret=0 break end end } } helpwindow.visible=false return ret end

def pbPrepareWindow(window) window.visible=true window.letterbyletter=false end

def pbStartBuyOrSellScene(buying,stock,adapter) # Scroll right before showing screen pbScrollMap(6,5,5) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @stock=stock @adapter=adapter @sprites={} @sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"].setBitmap("Graphics/Pictures/martScreen") @sprites["icon"]=IconSprite.new(12,Graphics.height-74,@viewport) winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter) @sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter, Graphics.width-316-16,12,330+16,Graphics.height-126) @sprites["itemwindow"].[email protected] @sprites["itemwindow"].index=0 @sprites["itemwindow"].refresh @sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("") pbPrepareWindow(@sprites["itemtextwindow"]) @sprites["itemtextwindow"].x=64 @sprites["itemtextwindow"].y=Graphics.height-96-16 @sprites["itemtextwindow"].width=Graphics.width-64 @sprites["itemtextwindow"].height=128 @sprites["itemtextwindow"].baseColor=Color.new(248,248,248) @sprites["itemtextwindow"].shadowColor=Color.new(0,0,0) @sprites["itemtextwindow"].visible=true @sprites["itemtextwindow"].[email protected] @sprites["itemtextwindow"].windowskin=nil @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["helpwindow"]) @sprites["helpwindow"].visible=false @sprites["helpwindow"].[email protected] pbBottomLeftLines(@sprites["helpwindow"],1) @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["moneywindow"]) @sprites["moneywindow"].visible=true @sprites["moneywindow"].[email protected] @sprites["moneywindow"].x=0 @sprites["moneywindow"].y=0 @sprites["moneywindow"].width=190 @sprites["moneywindow"].height=96 @sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].shadowColor=Color.new(168,184,184) pbDeactivateWindows(@sprites) @buying=buying pbRefresh Graphics.frame_reset end

def pbStartBuyScene(stock,adapter) pbStartBuyOrSellScene(true,stock,adapter) end

def pbStartSellScene(bag,adapter) if $PokemonBag pbStartSellScene2(bag,adapter) else pbStartBuyOrSellScene(false,bag,adapter) end end

def pbStartSellScene2(bag,adapter) @subscene=PokemonBag_Scene.new @adapter=adapter @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport2.z=99999 for j in 0..17 col=Color.new(0,0,0,j*15) @viewport2.color=col Graphics.update Input.update end @subscene.pbStartScene(bag) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @sprites={} @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["helpwindow"]) @sprites["helpwindow"].visible=false @sprites["helpwindow"].[email protected] pbBottomLeftLines(@sprites["helpwindow"],1) @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["moneywindow"]) @sprites["moneywindow"].visible=false @sprites["moneywindow"].[email protected] @sprites["moneywindow"].x=0 @sprites["moneywindow"].y=0 @sprites["moneywindow"].width=186 @sprites["moneywindow"].height=96 @sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].shadowColor=Color.new(168,184,184) pbDeactivateWindows(@sprites) @buying=false pbRefresh end

def pbShowMoney pbRefresh @sprites["moneywindow"].visible=true end

def pbHideMoney pbRefresh @sprites["moneywindow"].visible=false end

def pbEndBuyScene pbDisposeSpriteHash(@sprites) @viewport.dispose # Scroll left after showing screen pbScrollMap(4,5,5) end

def pbEndSellScene if @subscene @subscene.pbEndScene end pbDisposeSpriteHash(@sprites) if @viewport2 for j in 0..17 col=Color.new(0,0,0,(17-j)*15) @viewport2.color=col Graphics.update Input.update end @viewport2.dispose end @viewport.dispose if [email protected] pbScrollMap(4,5,5) end end

def pbDisplay(msg,brief=false) [email protected]["helpwindow"] cw.letterbyletter=true cw.text=msg pbBottomLeftLines(cw,2) cw.visible=true i=0 pbPlayDecisionSE() loop do Graphics.update Input.update self.update if brief && !cw.busy? return end if i==0 && !cw.busy? pbRefresh end if Input.trigger?(Input::C) && cw.busy? cw.resume end if i==60 return end i+=1 if !cw.busy? end end

def pbDisplayPaused(msg) [email protected]["helpwindow"] cw.letterbyletter=true cw.text=msg pbBottomLeftLines(cw,2) cw.visible=true i=0 pbPlayDecisionSE() loop do Graphics.update Input.update wasbusy=cw.busy? self.update if !cw.busy? && wasbusy pbRefresh end if Input.trigger?(Input::C) && cw.resume && !cw.busy? @sprites["helpwindow"].visible=false return end end end

def pbConfirm(msg) [email protected]["helpwindow"] dw.letterbyletter=true dw.text=msg dw.visible=true pbBottomLeftLines(dw,2) commands=[_INTL("Yes"),_INTL("No")] cw = Window_CommandPokemon.new(commands) [email protected] pbBottomRight(cw) cw.y-=dw.height cw.index=0 pbPlayDecisionSE() loop do cw.visible=!dw.busy? Graphics.update Input.update cw.update self.update if Input.trigger?(Input::B) && dw.resume && !dw.busy? cw.dispose @sprites["helpwindow"].visible=false return false end if Input.trigger?(Input::C) && dw.resume && !dw.busy? cw.dispose @sprites["helpwindow"].visible=false return (cw.index==0)?true:false end end end

def pbRefresh if [email protected] [email protected]["itemwindow"] [email protected](itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["icon"].[email protected](itemwindow.item) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @adapter.getDescription(itemwindow.item) itemwindow.refresh end @sprites["moneywindow"].text=_INTL("Coins\n<r> {1}",@adapter.getMoney()) end

def pbChooseBuyItem [email protected]["itemwindow"] @sprites["helpwindow"].visible=false pbActivateWindow(@sprites,"itemwindow"){ pbRefresh loop do Graphics.update Input.update olditem=itemwindow.item self.update if itemwindow.item!=olditem [email protected](itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["icon"].[email protected](itemwindow.item) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @adapter.getDescription(itemwindow.item) end if Input.trigger?(Input::B) return 0 end if Input.trigger?(Input::C) if itemwindow.index<@stock.length pbRefresh return @stock[itemwindow.index] else return 0 end end end } end =begin def pbChooseSellItem if @subscene return @subscene.pbChooseItem else return pbChooseBuyItem end end =end end

class PokemonMartCoinsScreen def initialize(scene,stock) @scene=scene @stock=stock @adapter=$PokemonBag ? PokemonMartCoinsAdapter.new : RpgxpMartAdapter.new end

def pbConfirm(msg) return @scene.pbConfirm(msg) end

def pbDisplay(msg) return @scene.pbDisplay(msg) end

def pbDisplayPaused(msg) return @scene.pbDisplayPaused(msg) end

def pbBuyScreen @scene.pbStartBuyScene(@stock,@adapter) item=0 loop do [email protected] quantity=0 break if item==0 [email protected](item) [email protected](item) if @adapter.getMoney()<price pbDisplayPaused(_INTL("You don't have enough money.")) next end if pbIsImportantItem?(item) if !pbConfirm(_INTL("Certainly. You want {1}.\r\nThat will be {2} Coins. OK?",itemname,price)) next end quantity=1 else maxafford=(price<=0) ? BAGMAXPERSLOT : @adapter.getMoney()/price maxafford=BAGMAXPERSLOT if maxafford>BAGMAXPERSLOT [email protected]( _INTL("{1}? Certainly.\r\nHow many would you like?",itemname),item,maxafford) if quantity==0 next end price*=quantity if !pbConfirm(_INTL("{1}, and you want {2}.\r\nThat will be {3} Coins. OK?",itemname,quantity,price)) next end end if @adapter.getMoney()<price pbDisplayPaused(_INTL("You don't have enough money.")) next end added=0 quantity.times do if [email protected](item) break end added+=1 end if added!=quantity added.times do if [email protected](item) raise _INTL("Failed to delete stored items") end end pbDisplayPaused(_INTL("You have no more room in the Bag.")) else @adapter.setMoney(@adapter.getMoney()-price) for i in 0...@stock.length if pbIsImportantItem?(@stock[i]) && $PokemonBag.pbQuantity(@stock[i])>0 @stock[i]=nil end end @stock.compact! pbDisplayPaused(_INTL("Here you are!\r\nThank you!")) if $PokemonBag if quantity>=10 && isConst?(item,PBItems,:POKEBALL) && hasConst?(PBItems,:PREMIERBALL) if @adapter.addItem(getConst(PBItems,:PREMIERBALL)) pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too.")) end end end end end @scene.pbEndBuyScene end =begin def pbSellScreen [email protected](@adapter.getInventory,@adapter) loop do [email protected] break if item==0 [email protected](item) [email protected](item) if [email protected]?(item) pbDisplayPaused(_INTL("{1}? Oh, no.\r\nI can't buy that.",itemname)) next end [email protected](item) next if qty==0 @scene.pbShowMoney if qty>1 [email protected]( _INTL("{1}?\r\nHow many would you like to sell?",itemname),item,qty) end if qty==0 @scene.pbHideMoney next end price/=2 price*=qty if pbConfirm(_INTL("I can pay ${1}.\r\nWould that be OK?",price)) @adapter.setMoney(@adapter.getMoney()+price) for i in 0...qty @adapter.removeItem(item) end pbDisplayPaused(_INTL("Turned over the {1} and received {2} Coins.",itemname,price)) end @scene.pbHideMoney end @scene.pbEndSellScene end =end end

=begin def pbBuyScreen @scene.pbStartBuyScene(@stock,@adapter) item=0 loop do [email protected] quantity=0 break if item==0 [email protected](item) [email protected](item) if @adapter.getMoney()<price pbDisplayPaused(_INTL("You don't have enough coins.")) next end if pbIsImportantItem?(item) if !pbConfirm(_INTL("Certainly. You want {1}.\r\nThat will be {2} Coins. OK?",itemname,price)) next end quantity=1 else maxafford=(price<=0) ? BAGMAXPERSLOT : @adapter.getMoney()/price maxafford=BAGMAXPERSLOT if maxafford>BAGMAXPERSLOT [email protected]( _INTL("{1}? Certainly.\r\nHow many would you like?",itemname),item,maxafford) if quantity==0 next end price*=quantity if !pbConfirm(_INTL("{1}, and you want {2}.\r\nThat will be {3} Coins. OK?",itemname,quantity,price)) next end end if @adapter.getMoney()<price pbDisplayPaused(_INTL("You don't have enough coins.")) next end added=0 quantity.times do if [email protected](item) break end added+=1 end if added!=quantity added.times do if [email protected](item) raise _INTL("Failed to delete stored items") end end pbDisplayPaused(_INTL("You have no more room in the Bag.")) else @adapter.setMoney(@adapter.getMoney()-price) for i in 0...@stock.length if pbIsImportantItem?(@stock[i]) && $PokemonBag.pbQuantity(@stock[i])>0 @stock[i]=nil end end @stock.compact! pbDisplayPaused(_INTL("Here you are!\r\nThank you!")) if $PokemonBag if quantity>=10 && isConst?(item,PBItems,:POKEBALL) && hasConst?(PBItems,:PREMIERBALL) if @adapter.addItem(getConst(PBItems,:PREMIERBALL)) pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too.")) end end end end end @scene.pbEndBuyScene end =end

def pbgamecorner(stock,speech=nil,cantsell=false) pbcoinvalue for i in 0...stock.length if pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0 stock[i]=nil end end stock.compact! commands=[] cmdBuy=-1 cmdQuit=-1 commands[cmdBuy=commands.length]=_INTL("Buy") commands[cmdQuit=commands.length]=_INTL("Quit") cmd=Kernel.pbMessage( speech ? speech : _INTL("Welcome!\r\nHow may I serve you?"), commands,cmdQuit+1) loop do if cmdBuy>=0 && cmd==cmdBuy scene=GameCornerScene.new screen=PokemonMartCoinsScreen.new(scene,stock) screen.pbBuyScreen else Kernel.pbMessage(_INTL("Please come again!")) break end cmd=Kernel.pbMessage( _INTL("Is there anything else I can help you with?"),commands,cmdQuit+1) end pbgoldvalue end

Reply With Quote
  #7    
Old February 2nd, 2014 (4:58 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,593

Now the default Essentials already has these features as sample events.

__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
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 GMT -8. The time now is 6:06 AM.