• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Pokémon Mart

Resource Pokémon Mart 1.0

~JV~

old school fangame developer
Member
Joined
Apr 18, 2017
Posts
8
~JV~ submitted a new resource:

Pokémon Mart - A Mart adapter for buying actual Pokémon

What is this?
A script for creating a Mart for buying Pokémon in the same style as the regular one. It is intended to be plug'n'play and pretty easy to use. This was born from a discussion on Discord and was made with a intention to show how easy it is to create a interface for buying (and selling) anything using any currency. This was made in under 30 mins and should be a good example on how to expand the regular mart feature. I have no plans on expanding this any...

Read more about this resource...
 

dreamaurua

Rookie
Member
Joined
Oct 7, 2020
Posts
5
What about the possibility to sell pokemon? how hard would it be to reverse this? I wanted to add another way to generate money in my game
 

Alweron

Rookie
Member
Joined
Dec 21, 2020
Posts
5
Hi, I'm trying to implement this awesome script, but get this error. As I am total noob in this area, I don't really know how to solve this. The issue may be that I'm using an older version of Essentials. To be more specific, I use a Pokémon Reborn as a base to create my own game...
By any chance, do you have some idea how to solve this?

1610394366190.png
 
Hi, I'm trying to implement this awesome script, but get this error. As I am total noob in this area, I don't really know how to solve this. The issue may be that I'm using an older version of Essentials. To be more specific, I use a Pokémon Reborn as a base to create my own game...
By any chance, do you have some idea how to solve this?

View attachment 1492
See where it says "Uninitialized constant PluginMananger"? That's telling you that "PluginMananger" hasn't been defined in your game, and the game's having an error because this script is referring to the plugin manager here:
Ruby:
Expand Collapse Copy
PluginManager.register({
  :name => "JV's Pokémon Mart",
  :version => "1.0",
  :credits => "JV",
  :link => "https://eeveeexpo.com/resources/464/"
})

The plugin manager was a featured added in v18 of Essentials. You could download a copy of it and just copy the script from there, or you could just remove this part of the script, since it's not required to make it function.
 

Alweron

Rookie
Member
Joined
Dec 21, 2020
Posts
5
See where it says "Uninitialized constant PluginMananger"? That's telling you that "PluginMananger" hasn't been defined in your game, and the game's having an error because this script is referring to the plugin manager here:
Ruby:
Expand Collapse Copy
PluginManager.register({
  :name => "JV's Pokémon Mart",
  :version => "1.0",
  :credits => "JV",
  :link => "https://eeveeexpo.com/resources/464/"
})

The plugin manager was a featured added in v18 of Essentials. You could download a copy of it and just copy the script from there, or you could just remove this part of the script, since it's not required to make it function.
Thanks, that was heplful and it solved the problem. I was able to implement the script and set up an event.
But...now I get this error instead.
1611382799133.png
 
Thanks, that was heplful and it solved the problem. I was able to implement the script and set up an event.
But...now I get this error instead.
That's saying that pbMessage isn't working with the code, which is weird, because that should just be defined by default. I'd suggest checking in Messages and making sure this is there:
Ruby:
Expand Collapse Copy
def pbMessage(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block)
  ret = 0
  msgwindow = pbCreateMessageWindow(nil,skin)
  if commands
    ret = pbMessageDisplay(msgwindow,message,true,
       proc { |msgwindow|
         next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
       },&block)
  else
    pbMessageDisplay(msgwindow,message,&block)
  end
  pbDisposeMessageWindow(msgwindow)
  Input.update
  return ret
end
Are you using a version before v17? That's when pbMessage was added.
 

Samdeman123124

Novice
Member
Joined
Jan 23, 2021
Posts
49
Hello, I am getting this error when I try to talk to the NPC...
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 18.1]

Exception: RuntimeError

Message: Script error within event 5 (coords 8,6), map 22 (Gardenia Cottage):

Exception: SyntaxError

Message: (eval):3:in `pbExecuteScript'compile error
(eval):3: syntax error



***Full script:

pbPokemonCreaturesMart([
[:TREECKO,0,5],]
])




Backtrace:





Backtrace:

Interpreter:246:in `pbExecuteScript'

Interpreter:1458:in `command_355'

Interpreter:359:in `execute_command'

Interpreter:155:in `update'

Interpreter:102:in `loop'

Interpreter:158:in `update'

Scene_Map:162:in `update'

Scene_Map:160:in `loop'

Scene_Map:169:in `update'

Scene_Map:229:in `main'



This exception was logged in

C:\Users\USERNAME\Saved Games\Pokemon Essentials\errorlog.txt.

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

Message: (eval):3:in `pbExecuteScript'compile error
(eval):3: syntax error
This is telling you that you have a syntax error. That means that something has a typo in it, something misspelled or some stray character.
pbPokemonCreaturesMart([
[:TREECKO,0,5],]
])
That last comma there, the one I bolded, that needs to be removed. It's telling the game to expect something after it, but there's nothing afterwards but the closing bracket, so it has a syntax error.
 

Alweron

Rookie
Member
Joined
Dec 21, 2020
Posts
5
That's saying that pbMessage isn't working with the code, which is weird, because that should just be defined by default. I'd suggest checking in Messages and making sure this is there:
Ruby:
Expand Collapse Copy
def pbMessage(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block)
  ret = 0
  msgwindow = pbCreateMessageWindow(nil,skin)
  if commands
    ret = pbMessageDisplay(msgwindow,message,true,
       proc { |msgwindow|
         next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
       },&block)
  else
    pbMessageDisplay(msgwindow,message,&block)
  end
  pbDisposeMessageWindow(msgwindow)
  Input.update
  return ret
end
Are you using a version before v17? That's when pbMessage was added.
This will be the problem! I am using Pokémon Reborn as a base which is built upon an older version of Essentials, although heavily modified. I have only PokemonMessages, not pbMessage and I believe these two do basically the same thing, but they use different names to call it. Or I am completely wrong :D

But after I added this piece of code, another error popped, which said I'm undefined method 'pbCreateMessageWindow'
So my wild guess is I keep adding these until it works? Hope it won't break something else...
 

Alweron

Rookie
Member
Joined
Dec 21, 2020
Posts
5
This will be the problem! I am using Pokémon Reborn as a base which is built upon an older version of Essentials, although heavily modified. I have only PokemonMessages, not pbMessage and I believe these two do basically the same thing, but they use different names to call it. Or I am completely wrong :D

But after I added this piece of code, another error popped, which said I'm undefined method 'pbCreateMessageWindow'
So my wild guess is I keep adding these until it works? Hope it won't break something else...
Okay, I've done exactly that and it works! I've added about five or six defining things. The only issue I see is that the pokémon does not disappear after being purchased, so in theory it can be purchased multiple times. And I'm not sure whether this is a bug or not...
 
Okay, I've done exactly that and it works! I've added about five or six defining things. The only issue I see is that the pokémon does not disappear after being purchased, so in theory it can be purchased multiple times. And I'm not sure whether this is a bug or not...
Yay, I'm glad that worked!

I think that's the intended function, since it's supposed to be like the mart, which has an unlimited supply. I know of a way to have a vendor sell something once, but it wouldn't have the UI of the mart...
 

Alweron

Rookie
Member
Joined
Dec 21, 2020
Posts
5
Yay, I'm glad that worked!

I think that's the intended function, since it's supposed to be like the mart, which has an unlimited supply. I know of a way to have a vendor sell something once, but it wouldn't have the UI of the mart...
Thanks for your help and your reply! I'm glad I was able to put this together. And yeah, I tested it in Essentials v.18 and it's supposed to be unlimited stock. Which is somewhat strange to me, but hey, I guess it does not matter, if I want something else, I can do it via events...
 

Aligatueur

Novice
Member
Joined
May 10, 2022
Posts
11
Heyah !
Sorry to dump that threrad, but I'm working on a little game, and I'd love have this on it.

The issue is that I'm using Pokemon Essentials 19.1 (with Gen 8 support) and it just doesn't work.
Seems there's an issue with the fact that the script uses the PBSpecies, but I don't want to break anything with my limited knowledge.

If there's any tip / help for that to make it work, it'd be amazing.
Thanks <3

Edit : I've found the fix somewhere, but maybe it'd still a good thing to update ?
 
Last edited:

Richard PT

Cooltrainer
Member
Joined
Oct 26, 2018
Posts
127
Please update the script for essentials v20, i just discovered this script and i think that i'll give it a try too.
 
Last edited:

Pokegeek

Rookie
Member
Joined
Jun 12, 2022
Posts
1
Is there anyway to sell/buy a certain form of a Pokémon?
 
Last edited:

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
Please update the script for essentials v20, i just discovered this script and i think that i'll give it a try too.
I know this was an old post, but if you still need it, and for anyone else looking, this should work in V20. I'm using it in my game. You can delete the top portion, where the stocks are, if you want to define them yourself in the event. I prefer to put them all in one place and imo, it's faster to type here than set up an event. To call it with the predefined lists, just use pbBlackmarket(Pseudo), pbBlackmarket(Starter), or pbBlackmarket(Legendary). You can still call pbBlackmarket([[:PIKACHU,12000,10]]) if you'd like. Feel free to change Blackmarket to whatever you want, just make sure you change all instances. I'm in no way a ruby programmer, but it works in my game, and I've tested in a clean copy of V20.


Ruby:
Expand Collapse Copy
# Predefined stock lists
# Predefined stock lists
Pseudo = [
  [:DRATINI, 20000, 10],
  [:LARVITAR, 20000, 12],
  [:BAGON, 20000, 10],
  [:EEVEE, 20000, 12],
  [:BELDUM, 20000, 10],
  [:GIBLE, 20000, 12],
  [:DEINO, 20000, 10],
  [:GOOMY, 20000, 12],
  [:JANGMOO, 20000, 10],
  [:DREEPY, 20000, 12],
  [:FRIGIBAX, 20000, 12],
  # Add more items as needed
]

Starter = [
  [:CHARMANDER, 15000, 8],
  [:SQUIRTLE, 15000, 8],
  [:CHARMANDER, 15000, 8],
  # Add more items as needed
]
Legendary= [
  [:MEWTWO, 50000, 50],
  [:MEW, 50000, 50],
  [:ARCEUS, 50000, 50],
  # Add more items as needed
]

def pbBlackmarket(stock, speech = nil)
  for i in 0...stock.length
    species_id = stock[i][0]
    species_data = GameData::Species.get(species_id)
    if !species_data || species_id == 0
      stock[i] = nil
    end
  end
  
  stock.compact!
  commands = []
  cmdBuy = -1
  cmdSell = -1
  cmdQuit = -1
  commands[cmdBuy = commands.length] = _INTL("Buy")
  commands[cmdQuit = commands.length] = _INTL("Quit")
  cmd = pbMessage(
   speech ? speech : _INTL("Welcome! How may I serve you?"), commands, cmdQuit + 1)
loop do
  if cmdBuy >= 0 && cmd == cmdBuy
    scene = Blackmarket_Scene.new
    screen = BlackmarketScreen.new(scene, stock)
    screen.pbBuyScreen
  else
    pbMessage(_INTL("Please come again!"))
    break
  end
  cmd = pbMessage(_INTL("Is there anything else I can help you with?"), commands, cmdQuit + 1)
end

  $game_temp.clear_mart_prices
end

class BlackmarketAdapter
  def initialize(stock)
    @stock = stock
  end

  def getMoney
    return $Trainer.money
  end

  def getMoneyString
    return pbGetGoldString
  end

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

  def getInventory
    return $Trainer.party
  end

def getDisplayName(item)
  species_data = GameData::Species.get(item)
  return nil unless species_data
  
  species_name = species_data.name
  level = @stock.find { |i| i[0] == item }&.fetch(2, 0)
  
  if level
    return "#{species_name} (Lv. #{level})"
  else
    return species_name
  end
end

  def getName(item)
    return GameData::Species.getName(item)
  end

def getDescription(item)
    if item.nil?
    return _INTL("Quit Shopping")
  else
    species_data = GameData::Species.get(item)
    return nil unless species_data
    description = species_data.pokedex_entry
  end
end


  def getItemIcon(item)
    return nil if !item
    file = pbCheckPokemonIconFiles([item,nil,nil,nil,nil],nil)
    return AnimatedBitmap.new(file).deanimate
  end

  def getItemIconRect(_item)
    return Rect.new(0,0,64,64)
  end

  def getQuantity(item)
    return nil
  end

  def showQuantity?(item)
    return false
  end

  def getPrice(item,selling=false)
    for i in @stock
      return i[1] if i[0] == item
    end
    return 10000
  end

  def getDisplayPrice(item,selling=false)
    price = getPrice(item,selling).to_s_formatted
    return _INTL("$ {1}",price)
  end

  def canSell?(item)
    return false
  end

  def addItem(item)
    level = 5
    for i in @stock
      level = i[2] if i[0] == item && i[2]
    end
    return pbAddPokemon(item,level)
  end

  def removeItem(item)
    return nil
  end
end

class BlackmarketScreen < PokemonMartScreen
  def initialize(scene,stock)
    @scene=scene
    @stock=[]
    @adapter=BlackmarketAdapter.new(stock)
    for i in stock
      @stock.push(i.first)
    end
  end
def pbBuyScreen
  @scene.pbStartBuyScene(@stock, @adapter)
  item = 0
  loop do
    item = @scene.pbChooseBuyItem
    quantity = 1
    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 !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
        itemname, price.to_s_formatted))
      next
    end
    unless pbBoxesFull?
      @adapter.setMoney(@adapter.getMoney - price)
      pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
      @adapter.addItem(item)
    else
      pbDisplayPaused(_INTL("You have no more room in the Storage."))
    end
  end
  @scene.pbEndBuyScene
end
end

class Blackmarket_Scene < PokemonMart_Scene
  def pbRefresh
    if @subscene
      @subscene.pbRefresh
    else
      itemwindow = @sprites["itemwindow"]
      @sprites["icon"].species = itemwindow.item
      
      item_description = @adapter.getDescription(itemwindow.item)
      description_text = (item_description.nil? || itemwindow.item == 0) ? _INTL("Quit shopping.") : "<fs=24>#{item_description}</fs>"
      
      @sprites["itemtextwindow"].text = description_text
      itemwindow.refresh
    end
    @sprites["moneywindow"].text = _INTL("Money:\r\n<r>{1}", @adapter.getMoneyString)
  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"]=PokemonSpeciesIconSprite.new(0,@viewport)
    @sprites["icon"].x = 4
    @sprites["icon"].y = Graphics.height-90
    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_AdvancedTextPokemon.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"].setSkin("Graphics/Windowskins/goldskin")
    @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 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
          @sprites["icon"].species=itemwindow.item
          @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
          "<fs=24>#{@adapter.getDescription(itemwindow.item)}</fs>"
        end
        if Input.trigger?(Input::B)
          pbPlayCloseMenuSE
          return 0
        elsif Input.trigger?(Input::C)
          if itemwindow.index<@stock.length
            pbRefresh
            return @stock[itemwindow.index]
          else
            return 0
          end
        end
      end
    }
  end
end
 
Back
Top