Community

The PokéCommunity

We are still working on a better slogan!

Visit Index



Advertise here

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Notices

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.

Post Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old July 25th, 2013, 06:15 PM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create

Advertise here
Why do I seem to get all of the errors? I guess i'll come here again. I made the Guy for my Pokemart. The thing is, when i talk to him in-game, he gives me an error report. Any help? I am not sure what version of Essentials we are using. I should probably upgrade to V12 soon.

Spoiler:

---------------------------
Apex 0.60a
---------------------------
Exception: RuntimeError

Message: Script error within event 1, map 6 (PokeCenter):

Exception: TypeError

Message: Section141:382:in `[]'Symbol as array index

***Full script:

pbPokemonMart([
:POKEBALL,
:POTION,
:ANTIDOTE,
:PARLYZHEAL,
:ESCAPEROPE,
:REPEL
])


Interpreter:243:in `pbExecuteScript'

Compiler:382:in `[]'

PokemonItems:31:in `pbIsImportantItem?'

PokemonMart:775:in `pbPokemonMart'

PokemonMart:774:in `each'

PokemonMart:774:in `pbPokemonMart'

(eval):8:in `pbExecuteScript'

Interpreter:1599:in `eval'

Interpreter:243:in `pbExecuteScript'

Interpreter:1599:in `command_355'



Interpreter:276:in `pbExecuteScript'

Interpreter:1599:in `command_355'

Interpreter:494:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:103:in `update'

Scene_Map:101:in `loop'

Scene_Map:114:in `update'

Scene_Map:68:in `main'



This exception was logged in ./errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #2    
Old July 25th, 2013, 08:36 PM
jim42's Avatar
jim42
 
Join Date: Jul 2009
Gender: Male
You dropped the closing square bracket and parenthesis after :REPEL onto the next line. Lines are only allowed to end on a comma or a parenthesis/bracket.
  #3    
Old July 25th, 2013, 11:33 PM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
Quote:
Originally Posted by jim42 View Post
You dropped the closing square bracket and parenthesis after :REPEL onto the next line. Lines are only allowed to end on a comma or a parenthesis/bracket.
YOu've got to be kidding me. Thats all thats wrong? O_O
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #4    
Old July 26th, 2013, 05:43 AM
jim42's Avatar
jim42
 
Join Date: Jul 2009
Gender: Male
Nah, no kidding here. Ruby is a very syntax-pedantic language from my experience. There are a lot of things that are implicit and assumed where in other languages it would be expressly defined. The reason this can work is because it enforces a very strict syntax for its code. Since lines are ended at the physical end of the line, rather than with a defined character (often a semicolon), you have to ensure that any time that you do have to chop a line down, it is done so in one of the few ways that Ruby can see that "hey, this line is actually still going, man"; that is, commas, parenthesis and brackets.
  #5    
Old July 26th, 2013, 06:21 AM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
Quote:
Originally Posted by jim42 View Post
Nah, no kidding here. Ruby is a very syntax-pedantic language from my experience. There are a lot of things that are implicit and assumed where in other languages it would be expressly defined. The reason this can work is because it enforces a very strict syntax for its code. Since lines are ended at the physical end of the line, rather than with a defined character (often a semicolon), you have to ensure that any time that you do have to chop a line down, it is done so in one of the few ways that Ruby can see that "hey, this line is actually still going, man"; that is, commas, parenthesis and brackets.
Okay, then what about this?
Spoiler:

---------------------------
Apex 0.60a
---------------------------
Exception: RuntimeError

Message: Script error within event 1, map 6 (PokeCenter):

Exception: TypeError

Message: Section141:382:in `[]'Symbol as array index

***Full script:

pbPokemonMart([
OKEBALL,
OTION,
:ANTIDOTE,
ARLYZHEAL,
:ESCAPEROPE,
:REPEL])


Interpreter:243:in `pbExecuteScript'

Compiler:382:in `[]'

PokemonItems:31:in `pbIsImportantItem?'

PokemonMart:775:in `pbPokemonMart'

PokemonMart:774:in `each'

PokemonMart:774:in `pbPokemonMart'

(eval)in `pbExecuteScript'

Interpreter:1599:in `eval'

Interpreter:243:in `pbExecuteScript'

Interpreter:1599:in `command_355'



Interpreter:276:in `pbExecuteScript'

Interpreter:1599:in `command_355'

Interpreter:494:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:103:in `update'

Scene_Map:101:in `loop'

Scene_Map:114:in `update'

Scene_Map:68:in `main'



This exception was logged in ./errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------


From what i see in the error, it's telling me the array is messed up? I might be reading that wrong. I have editted it around and can't seem to fix it. It says something about Pbisimportantitem?
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #6    
Old July 26th, 2013, 08:57 AM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Have a look at the top of def pbPokemonMart. Does it look like this:

Code:
def pbPokemonMart(stock,speech=nil,cantsell=false)
  for i in 0...stock.length
    stock[i]=getID(PBItems,stock[i]) if !stock[i].is_a?(Integer)
    if !stock[i] || stock[i]==0 ||
       (pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0)
      stock[i]=nil
    end
  end
  stock.compact!
  commands=[]
Because it should.

:POTION, with the colon in front of it, is what's known as a symbol. It needs to be turned into an integer, which is what the getID method does. That's the really important line, and it needs to happen before you try using it to look up information from an array (which is what pbIsImportantItem? does).
  #7    
Old July 26th, 2013, 08:59 AM
jim42's Avatar
jim42
 
Join Date: Jul 2009
Gender: Male
Okay, I've looked at the examples in my clean Essentials 12. It seems that closing brackets/parentheses can be on the next line. My bad. Anyway, that's not relevant to the problem.

That IsImportantItem thing returns true if the item passed to it is a key item, an HM or a TM if Gen V TMs are in effect. It is called by PokemonMart with a bit of code that examine the array of items passed (your list) and discards any value that is either a) not an item, b) equal to 0 or c) a key item that has already been acquired.

Now, I can't see anything there that should be subject to IsImportantItem, but you're getting an error there nonetheless. The only thing I can think of is that, in an older version of Essentials, OKEBALL was formatted differently. If you're using one of those versions, then the formatting discrepancy may be the root of the solution. Take a look at the raw Essentials for whatever version you're using, and see what the example Mart script says.
  #8    
Old July 26th, 2013, 12:04 PM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
Quote:
Originally Posted by Maruno View Post
Have a look at the top of def pbPokemonMart. Does it look like this:

Code:
def pbPokemonMart(stock,speech=nil,cantsell=false)
  for i in 0...stock.length
    stock[i]=getID(PBItems,stock[i]) if !stock[i].is_a?(Integer)
    if !stock[i] || stock[i]==0 ||
       (pbIsImportantItem?(stock[i]) && $PokemonBag.pbQuantity(stock[i])>0)
      stock[i]=nil
    end
  end
  stock.compact!
  commands=[]
Because it should.

OTION, with the colon in front of it, is what's known as a symbol. It needs to be turned into an integer, which is what the getID method does. That's the really important line, and it needs to happen before you try using it to look up information from an array (which is what pbIsImportantItem? does).
The PokemonMart script i have is:
Spoiler:

Code:
# Abstraction layer for Pokemon Essentials
class PokemonMartAdapter
  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 sprintf("Graphics/Icons/itemBack") if item==0
    return !item ? nil : sprintf("Graphics/Icons/item%03d",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}",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



# Abstraction layer for RPG Maker XP/VX
class RpgxpMartAdapter
  def getMoney
    return $game_party.gold
  end

  def setMoney(value)
    $game_party.gain_gold(-$game_party.gold)
    $game_party.gain_gold(value)
  end

  def getPrice(item)
    return item.price
  end

  def getItemIcon(item)
    if !item
      return nil
    elsif item==0 
      return sprintf("Graphics/Icons/itemBack")
    elsif item.respond_to?("icon_index")
      return "Graphics/System/IconSet"
    else
      return sprintf("Graphics/Icons/%s",item.icon_name)
    end
  end

  def getItemIconRect(item)
    if item && item.respond_to?("icon_index")
      ix=item.icon_index % 16 * 24
      iy=item.icon_index / 16 * 24
      return Rect.new(ix,iy,24,24)
    else
      return Rect.new(0,0,32,32)
    end
  end

  def getInventory()
    data = []
    for i in 1...$data_items.size
      if getQuantity($data_items[i]) > 0
        data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if getQuantity($data_weapons[i]) > 0
        data.push($data_weapons[i])
     end
    end
    for i in 1...$data_armors.size
      if getQuantity($data_armors[i]) > 0
        data.push($data_armors[i])
      end
    end
    return data
  end

  def canSell?(item)
    return item ? item.price>0 : false
  end

  def getName(item)
    return item ? item.name : ""
  end

  def getDisplayName(item)
    return item ? item.name : ""
  end

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

  def getDescription(item)
    return item ? item.description : ""
  end

  def addItem(item)
    ret=(getQuantity(item)<99)
    if $game_party.respond_to?("gain_weapon")
      case item
        when RPG::Item
          $game_party.gain_item(item.id, 1) if ret
        when RPG::Weapon
          $game_party.gain_weapon(item.id, 1) if ret
        when RPG::Armor
          $game_party.gain_armor(item.id, 1) if ret
      end
    else
      $game_party.gain_item(item,1) if ret
    end
    return ret
  end

  def getQuantity(item)
    ret=0
    if $game_party.respond_to?("weapon_number")
      case item
        when RPG::Item
          ret=$game_party.item_number(item.id)
        when RPG::Weapon
          ret=($game_party.weapon_number(item.id))
        when RPG::Armor
          ret=($game_party.armor_number(item.id))
      end
    else
      return $game_party.item_number(item)
    end
    return ret
  end

  def showQuantity?(item)
    return true
  end

  def removeItem(item)
    ret=(getQuantity(item)>0)
    if $game_party.respond_to?("lose_weapon")
      case item
        when RPG::Item
          $game_party.lose_item(item.id, 1) if ret
        when RPG::Weapon
          $game_party.lose_weapon(item.id, 1) if ret
        when RPG::Armor
          $game_party.lose_armor(item.id, 1) if ret
      end
    else
      $game_party.lose_item(item,1) if ret
    end
    return ret
  end
end


###################


class Window_PokemonMart < Window_DrawableCommand
  def initialize(stock,adapter,x,y,width,height,viewport=nil)
    @stock=stock
    @adapter=adapter
    super(x,y,width,height,viewport)
    @selarrow=AnimatedBitmap.new("Graphics/Pictures/martSel")
    @baseColor=Color.new(88,88,80)
    @shadowColor=Color.new(168,184,184)
    self.windowskin=nil
  end

  def itemCount
    return @stock.length+1
  end

  def item
    return self.index>=@stock.length ? 0 : @stock[self.index]
  end

  def drawItem(index,count,rect)
    textpos=[]
    rect=drawCursor(index,rect)
    ypos=rect.y
    if index==count-1
      textpos.push([_INTL("CANCEL"),rect.x,ypos+2,false,
         self.baseColor,self.shadowColor])
    else
      item=@stock[index]
      itemname=@adapter.getDisplayName(item)
      qty=@adapter.getDisplayPrice(item)
      sizeQty=self.contents.text_size(qty).width
      xQty=rect.x+rect.width-sizeQty-2-16
      textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor])
      textpos.push([qty,xQty,ypos+2,false,self.baseColor,self.shadowColor])
    end
    pbDrawTextPositions(self.contents,textpos)
  end
end



class BuyAdapter # :nodoc:
  def initialize(adapter)
    @adapter=adapter
  end

  def getDisplayName(item)
    @adapter.getDisplayName(item)
  end

  def getDisplayPrice(item)
    @adapter.getDisplayPrice(item)
  end
end



class SellAdapter # :nodoc:
  def initialize(adapter)
    @adapter=adapter
  end

  def getDisplayName(item)
    @adapter.getDisplayName(item)
  end

  def getDisplayPrice(item)
    if @adapter.showQuantity?(item)
      return sprintf("x%d",@adapter.getQuantity(item))
    else
      return ""
    end
  end
end



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

  def pbChooseNumber(helptext,item,maximum)
    curnumber=1
    ret=0
    helpwindow=@sprites["helpwindow"]
    itemprice=@adapter.getPrice(item)
    itemprice/=2 if !@buying
    pbDisplay(helptext,true)
    using(numwindow=Window_AdvancedTextPokemon.new("")){ # Showing number of items
       qty=@adapter.getQuantity(item)
       using(inbagwindow=Window_AdvancedTextPokemon.new("")){ # Showing quantity in bag
          pbPrepareWindow(numwindow)
          pbPrepareWindow(inbagwindow)
          numwindow.viewport=@viewport
          numwindow.width=224
          numwindow.height=64
          numwindow.baseColor=Color.new(88,88,80)
          numwindow.shadowColor=Color.new(168,184,184)
          inbagwindow.visible=@buying
          inbagwindow.viewport=@viewport
          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"].viewport=@viewport
    @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"].viewport=@viewport
    @sprites["itemtextwindow"].windowskin=nil
    @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("")
    pbPrepareWindow(@sprites["helpwindow"])
    @sprites["helpwindow"].visible=false
    @sprites["helpwindow"].viewport=@viewport
    pbBottomLeftLines(@sprites["helpwindow"],1)
    @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
    pbPrepareWindow(@sprites["moneywindow"])
    @sprites["moneywindow"].visible=true
    @sprites["moneywindow"].viewport=@viewport
    @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"].viewport=@viewport
    pbBottomLeftLines(@sprites["helpwindow"],1)
    @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
    pbPrepareWindow(@sprites["moneywindow"])
    @sprites["moneywindow"].visible=false
    @sprites["moneywindow"].viewport=@viewport
    @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 !@subscene
      pbScrollMap(4,5,5)
    end
  end

  def pbDisplay(msg,brief=false)
    cw=@sprites["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)
    cw=@sprites["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)
    dw=@sprites["helpwindow"]
    dw.letterbyletter=true
    dw.text=msg
    dw.visible=true
    pbBottomLeftLines(dw,2)
    commands=[_INTL("Yes"),_INTL("No")]
    cw = Window_CommandPokemon.new(commands)
    cw.viewport=@viewport
    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 !@subscene
      itemwindow=@sprites["itemwindow"]
      filename=@adapter.getItemIcon(itemwindow.item)
      @sprites["icon"].setBitmap(filename)
      @sprites["icon"].src_rect=@adapter.getItemIconRect(itemwindow.item)   
      @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
         @adapter.getDescription(itemwindow.item)
      itemwindow.refresh
    end
    @sprites["moneywindow"].text=_INTL("Money\n<r>$ {1}",@adapter.getMoney())
  end

  def pbChooseBuyItem
    itemwindow=@sprites["itemwindow"]
    @sprites["helpwindow"].visible=false
    pbActivateWindow(@sprites,"itemwindow"){
       pbRefresh
       loop do
         Graphics.update
         Input.update
         olditem=itemwindow.item
         self.update
         if itemwindow.item!=olditem
           filename=@adapter.getItemIcon(itemwindow.item)
           @sprites["icon"].setBitmap(filename)
           @sprites["icon"].src_rect=@adapter.getItemIconRect(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


#######################################################


class PokemonMartScreen
  def initialize(scene,stock)
    @scene=scene
    @stock=stock
    @adapter=$PokemonBag ? PokemonMartAdapter.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
      item=@scene.pbChooseBuyItem
      quantity=0
      break if item==0
      itemname=@adapter.getDisplayName(item)
      price=@adapter.getPrice(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}.  OK?",itemname,price))
          next
        end
        quantity=1
      else
        maxafford=(price<=0) ? 99 : @adapter.getMoney()/price
        maxafford=99 if maxafford>99
        quantity=@scene.pbChooseNumber(
           _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}.  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 !@adapter.addItem(item)
          break
        end
        added+=1
      end
      if added!=quantity
        added.times do
          if !@adapter.removeItem(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

  def pbSellScreen
    item=@scene.pbStartSellScene(@adapter.getInventory,@adapter)
    loop do
      item=@scene.pbChooseSellItem
      break if item==0
      itemname=@adapter.getDisplayName(item)
      price=@adapter.getPrice(item)
      if !@adapter.canSell?(item)
        pbDisplayPaused(_INTL("{1}?  Oh, no.\r\nI can't buy that.",itemname))
        next
      end
      qty=@adapter.getQuantity(item)
      next if qty==0
      @scene.pbShowMoney
      if qty>1
        qty=@scene.pbChooseNumber(
           _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}.",itemname,price))
      end
      @scene.pbHideMoney
    end
    @scene.pbEndSellScene
  end
end



def pbPokemonMart(stock,speech=nil,cantsell=false)
  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
  cmdSell=-1
  cmdQuit=-1
  commands[cmdBuy=commands.length]=_INTL("Buy")
  commands[cmdSell=commands.length]=_INTL("Sell") if !cantsell
  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=PokemonMartScene.new
      screen=PokemonMartScreen.new(scene,stock)
      screen.pbBuyScreen
    elsif cmdSell>=0 && cmd==cmdSell
      scene=PokemonMartScene.new
      screen=PokemonMartScreen.new(scene,stock)
      screen.pbSellScreen
    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
end



class Interpreter
  def getItem(p)
    if p[0]==0
      return $data_items[p[1]]
    elsif p[0]==1
      return $data_weapons[p[1]]
    elsif p[0]==2
      return $data_armors[p[1]]
    end
    return nil
  end

  def command_302
    $game_temp.battle_abort = true
    shop_goods = [getItem(@parameters)]
    # Loop
    loop do
      # Advance index
      @index += 1
      # If next event command has shop on second line or after
      if @list[@index].code == 605
        # Add goods list to new item
        shop_goods.push(getItem(@list[@index].parameters))
      else
        # End
        pbPokemonMart(shop_goods.compact)
        return true
      end
    end
  end
end



class Game_Interpreter
  def getItem(p)
    if p[0]==0
      return $data_items[p[1]]
    elsif p[0]==1
      return $data_weapons[p[1]]
    elsif p[0]==2
      return $data_armors[p[1]]
    end
    return nil
  end

  def command_302
    shop_goods = [getItem(@params)]
    # Loop
    loop do
      # Advance index
      @index += 1
      # If next event command has shop on second line or after
      if @list[@index].code == 605
        # Add goods list to new item
        shop_goods.push(getItem(@list[@index].parameters))
      else
        # End
        pbPokemonMart(shop_goods.compact,nil,@params[2])
        return true
      end
    end
  end
end
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #9    
Old July 26th, 2013, 01:32 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
You're using an old version of Essentials which doesn't support this:

Code:
pbPokemonMart([
:POKEBALL,
:POTION,
:ANTIDOTE,
:PARLYZHEAL,
:ESCAPEROPE,
:REPEL
])
You need to use this instead:
Code:
pbPokemonMart([
PBItems::POKEBALL,
PBItems::POTION,
PBItems::ANTIDOTE,
PBItems::PARLYZHEAL,
PBItems::ESCAPEROPE,
PBItems::REPEL
])
Also, you obviously didn't read what I said, even though what I said was the answer.
  #10    
Old July 26th, 2013, 02:13 PM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
Quote:
Originally Posted by Maruno View Post
You're using an old version of Essentials which doesn't support this:

Code:
pbPokemonMart([
:POKEBALL,
:POTION,
:ANTIDOTE,
:PARLYZHEAL,
:ESCAPEROPE,
:REPEL
])
You need to use this instead:
Code:
pbPokemonMart([
PBItems::POKEBALL,
PBItems::POTION,
PBItems::ANTIDOTE,
PBItems::PARLYZHEAL,
PBItems::ESCAPEROPE,
PBItems::REPEL
])
Also, you obviously didn't read what I said, even though what I said was the answer.
Well, considering since as short as it was, i thought it was a snippet, not the entire code. Second, I did read your answer, you didnt tell me to add "PBItems:" to the front of all of the things i want to sell.
But anyways, Thanks, because it works now.(I REALLY need to learn to script dammit)
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
  #11    
Old July 26th, 2013, 02:28 PM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Quote:
Originally Posted by Maruno View Post
Have a look at the top of def pbPokemonMart. Does it look like this:
.
.
.
Because it should.
In other words: "make this part of your code look like this." I don't think it was that subtle a message.

The alternative solution is to put PBItems: everywhere. I said this because I was surprised you didn't pick up on the first solution.
  #12    
Old July 26th, 2013, 04:16 PM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Harvey, why don't you just upgraded to 12.1... Saves all these unnecessary problems, and we can all help you quicker and more effective, sometimes we don't have time to look up older versions for simple problems as this, just some advice, because all these errors you're posting and things you want doing, you're not telling people you're using an older version which is confusing everyone. Consider it. I would.
  #13    
Old July 27th, 2013, 12:49 AM
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
Quote:
Originally Posted by Nickalooose View Post
Harvey, why don't you just upgraded to 12.1... Saves all these unnecessary problems, and we can all help you quicker and more effective, sometimes we don't have time to look up older versions for simple problems as this, just some advice, because all these errors you're posting and things you want doing, you're not telling people you're using an older version which is confusing everyone. Consider it. I would.
Well, i would upgrade, but I am not the one fully in charge of Apex, so i can't do things like that. I'll take to Dillon later about upgrading to 12.1
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Post Reply
Quick Reply

Sponsored Links


Advertise here
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 12:46 PM.

About Us
© 2002 - 2014 The PokéCommunity™, pokecommunity.com. Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.

Copyright
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com. PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator. Header artwork by Jordanice of deviantART.

Social Media
If you would like to stay up-to-date with us on the go, when we're down, or other such things, follow us on social media sites--most notibly Twitter, Facebook, and Google Plus--by clicking on the links provided.

Design presented by Peitharchia. Special thanks to Hiroshi Sotomura and Ausaudriel.