• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Item Crafter Scene

PunkPhantom

"midna's a cat" -vinny, vinesauce
78
Posts
10
Years
  • Age 29
  • Seen Nov 20, 2016
I'm trying to make it so you don't have to unlock any of the recipes, i also want to remove the Pokeball, Greatball, and Ultraball recipes, but i'm a little confused how. Sorry I don't know Ruby.
 
38
Posts
8
Years
  • Age 32
  • Seen Nov 26, 2023
its very nice, but, for some reason it return just 'UNKNOW' values and didnt show the sprites of itens that i set or the balls. what i need to do?
 
119
Posts
10
Years
its very nice, but, for some reason it return just 'UNKNOW' values and didnt show the sprites of itens that i set or the balls. what i need to do?

its because the recipes are probably locked. but i need to edit this script anyways. its old and i realize that i did the unlocking system kind of wrong. as well as ill make 2 versions. one that has the locked recipes and one without.
 
38
Posts
8
Years
  • Age 32
  • Seen Nov 26, 2023
And how can i unlock manually? :X

its very very nice and i need this to survive :c XDD
 
68
Posts
8
Years
  • Age 27
  • Seen Dec 3, 2016
Ok I gave an NPC this:
ItemHandlers::UseFromBag.add(:MOONBALL,proc{|item|
Kernel.pbMessage(_INTL("{1} used the {2}.",$Trainer.name,PBItems.getName(item)))
ItemCrafterScene.new
next 1
})

But nothing happens?
 
61
Posts
7
Years
I really like this <3 its exactly what I was looking for for my Pokemon Game I even made a Sprite for the on the go Item Crafter

Item_Crafter.png
 
24
Posts
10
Years
  • Age 31
  • Seen Jul 5, 2018
When unlocking a crafting recipe it becomes locked again after closing the game and opening it again.
 
178
Posts
10
Years
How do you turn it into an event?

There's instructions in the first part of the script. Probably you need to make an event, go the last page and click the command that reads "script" and put something there. Don't forgot to use extendtext while using the scripts command, it's in the root folder of your project (the same folder where the game.exe is).
 

Linkarnation

Salyhin
4
Posts
9
Years
  • Age 26
  • Seen Jan 19, 2019
I think it would be best if you were to show an example instead because I'm stupid
 
Last edited:
178
Posts
10
Years
Code:
# *To call put ItemCrafterScene.new in an event
It's literally in the instructions (which seemed pretty complete for me).
It should look like this in the event window:

Code:
@>Script: ItemCrafterScene.new

There's an event command called "Script...". Put the code in there and see how it works.
Just note that the script is old and may not work right out the box with essentials 17.2 and you would need to make changes yourself if thats the case. I'm not an scripter and cannot help you more than that.
 
Last edited:
30
Posts
6
Years
Hi, I would just like to share a more updated version of this script.
*Please remember to give credits to TheKrazyGamer/kcgcrazy/TheKraazyGamer.
You can use the graphics provided by the original link.

Just like to thank Vendily for being such a kind person :).

Code:
#===============================================================================
#                              *Item Crafter
# *Item Crafter scene created by TheKrazyGamer/kcgcrazy/TheKraazyGamer
# *Please Give Credit if used
#
# *to add an item of your own just add it to the RECIPES array.
#   Add The ITEMID,AMOUNT to be crafted,required MATERIALS and COSTS
#   and also BOOLEAN values for it being unlocked or not.
#   If a Second Material is not being used, enter nil.
#
#   Here is an example!
#
# RECIPES=[
#  [:ITEMID,CRAFT_AMOUNT,[:MATERIAL1,COST],[:MATERIAL2,COST],IS_UNLOCKED?]
#  ]
############################################################
# RECIPES=[
# [:POKEBALL,1,[:WHTAPRICORN,5],nil,false],
# [:GREATBALL,1,[:WHTAPRICORN,15],[:BLKAPRICORN,5],false],
# [:ULTRABALL,1,[:WHTAPRICORN,15],[:GRNAPRICORN,15],false],
# [:DIVEBALL,1,[:WHTAPRICORN,3],[:PNKAPRICORN,3],false]
# ]
#
############################################################
#
#  *To call put ItemCrafterScene.new in an event 
#   or create an item like this
#
# #Item Crafter
# ItemHandlers::UseFromBag.add(:ITEMCRAFTER,proc{|item|
#     Kernel.pbMessage(_INTL("{1} used the {2}.",$Trainer.name,PBItems.getName(item)))
#       ItemCrafterScene.new
#     next 1
#  })
#
# and add this to the Items.txt
# XXX,ITEMCRAFTER,Item Crafter,8,0,"Lets you craft items.",2,0,6,
# XXX - This is the number you can use in items.txt
# Create an item in icons folder with that number.
#
# To unlock an item that was set as false, just add the following after an event:
# $game_variables[CRAFTVAR][x]=true # x being the item index (count from 0 for the first etc)
#
# And Finally...
#
# Add setupCraftUnlocks to an event in the Intro Event to initialize
# The $game_variables.
#
#
#===============================================================================

CRAFTVAR = 100 # number used for available $game_variable.

$exit = 0
$isUnlocked = []
###############################################################################
# This is your Items, Material etc.
###############################################################################

RECIPES=[
[:POKEBALL,3,[:REDAPRICORN,2],nil, false],
[:GREATBALL,3,[:REDAPRICORN,2],[:BLUAPRICORN,2], false],
[:ULTRABALL,3,[:BLKAPRICORN,2],[:YLWAPRICORN,2], false],
[:DIVEBALL,3,[:PNKAPRICORN,2],[:BLUAPRICORN,2], false],
[:DUSKBALL,3,[:BLKAPRICORN,2],[:BLUAPRICORN,2], false],
[:FASTBALL,3,[:REDAPRICORN,2],[:YLWAPRICORN,2], false],
[:FRIENDBALL,3,[:GRNAPRICORN,2],[:YLWAPRICORN,2], false],
[:HEALBALL,3,[:PNKAPRICORN,2],[:WHTAPRICORN,2], false],
[:HEAVYBALL,3,[:BLUAPRICORN,2],nil, false],
[:LEVELBALL,3,[:BLKAPRICORN,2],[:REDAPRICORN,2], false],
[:LOVEBALL,3,[:WHTAPRICORN,2],nil, false],
[:LUXURYBALL,3,[:REDAPRICORN,2],[:WHTAPRICORN,2], false],
[:MOONBALL,3,[:BLKAPRICORN,2],[:BLUAPRICORN,2], false],
[:NESTBALL,3,[:GRNAPRICORN,2],[:YLWAPRICORN,2], false],
[:NETBALL,3,[:BLKAPRICORN,2],[:BLUAPRICORN,2], false],
[:PREMIERBALL,3,[:REDAPRICORN,2],[:WHTAPRICORN,2], false],
[:REPEATBALL,3,[:REDAPRICORN,2],[:BLKAPRICORN,2], false],
[:TIMERBALL,3,[:WHTAPRICORN,2],[:BLKAPRICORN,2], false]
]

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

# This goes through the RECIPES array and adds the true or false value from it
# to the $game_variables[CRAFTVAR] array
    for i in 0...RECIPES.length
     $isUnlocked[i] = RECIPES[i][4]
    end
   
  def setupCraftUnlocks
   $game_variables[CRAFTVAR] = $isUnlocked
  end

#From here onwards you DO NOT change anything.
class ItemCrafterScene

  def initialize
    @close = $exit
    @select=3
    @item=0
    @mat1=RECIPES[@item][2]? RECIPES[@item][2][0] : -1 # the amount for first item
    @mat2=RECIPES[@item][3]? RECIPES[@item][3][0] : -1 # the amount for first item
    @cost1=RECIPES[@item][2]? RECIPES[@item][2][1] : 0 # the amount for first item
    @cost2=RECIPES[@item][3]? RECIPES[@item][3][1] : 0 # the amount for first item
    @amount=RECIPES[@item][1] # the amount for the first item made
                  
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @sprites={}

    @sprites["bg"]=IconSprite.new(0,0,@viewport)    
    @sprites["bg"].setBitmap("Graphics/Pictures/ItemCrafter/BG")
    
    @sprites["Item"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item"].setBitmap("Graphics/Pictures/ItemCrafter/Item_BG")
    @sprites["Item"].x=210+10
    @sprites["Item"].y=30
     
    @sprites["Item_Hov"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_Hov"].setBitmap("Graphics/Pictures/ItemCrafter/ItemHov_BG")
    @sprites["Item_Hov"].x=210+10
    @sprites["Item_Hov"].y=30
    @sprites["Item_Hov"].opacity=0
    
    @sprites["Item_icon"]=IconSprite.new(0,0,@viewport)   
    @sprites["Item_icon"].setBitmap(pbItemIconFile(getID(PBItems,RECIPES[@item][0])))
    @sprites["Item_icon"].x=220+10
    @sprites["Item_icon"].y=40
    @sprites["Item_icon"].opacity=0
    
    @sprites["unknown"]=IconSprite.new(0,0,@viewport)    
    @sprites["unknown"].setBitmap("Graphics/Pictures/ItemCrafter/unknown")
    @sprites["unknown"].x=220
    @sprites["unknown"].y=30
    
    @sprites["Item_1"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_1"].setBitmap("Graphics/Pictures/ItemCrafter/ItemR_BG")
    @sprites["Item_1"].x=65
    @sprites["Item_1"].y=100
    
    @sprites["Item_1_icon"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_1_icon"].setBitmap((@mat1!=-1) ? pbItemIconFile(getID(PBItems,@mat1)) : "")
    @sprites["Item_1_icon"].x=65+10
    @sprites["Item_1_icon"].y=100+10
    @sprites["Item_1_icon"].opacity=0
    
    @sprites["Item_1_name"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_1_name"].setBitmap("Graphics/Pictures/ItemCrafter/Item_Name")
    @sprites["Item_1_name"].x=140
    @sprites["Item_1_name"].y=110
    
    @sprites["Item_2"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_2"].setBitmap("Graphics/Pictures/ItemCrafter/ItemR_BG")
    @sprites["Item_2"].x=65
    @sprites["Item_2"].y=185
    
    @sprites["Item_2_icon"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_2_icon"].setBitmap((@mat2!=-1) ? pbItemIconFile(getID(PBItems,@mat2)) : "")
    @sprites["Item_2_icon"].x=65+10
    @sprites["Item_2_icon"].y=185+10
    @sprites["Item_2_icon"].opacity=0
    
    @sprites["Item_2_name"]=IconSprite.new(0,0,@viewport)    
    @sprites["Item_2_name"].setBitmap("Graphics/Pictures/ItemCrafter/Item_Name")
    @sprites["Item_2_name"].x=140
    @sprites["Item_2_name"].y=198
    
    @sprites["Confirm"]=IconSprite.new(0,0,@viewport)    
    @sprites["Confirm"].setBitmap("Graphics/Pictures/ItemCrafter/Selection")
    @sprites["Confirm"].x=115
    @sprites["Confirm"].y=280
    
    @sprites["Confirm_Hov"]=IconSprite.new(0,0,@viewport)    
    @sprites["Confirm_Hov"].setBitmap("Graphics/Pictures/ItemCrafter/Selection_1")
    @sprites["Confirm_Hov"].x=115
    @sprites["Confirm_Hov"].y=280
    @sprites["Confirm_Hov"].opacity=0
    
    @sprites["Cancel"]=IconSprite.new(0,0,@viewport)    
    @sprites["Cancel"].setBitmap("Graphics/Pictures/ItemCrafter/Selection")
    @sprites["Cancel"].x=115
    @sprites["Cancel"].y=330
    
    @sprites["Cancel_Hov"]=IconSprite.new(0,0,@viewport)    
    @sprites["Cancel_Hov"].setBitmap("Graphics/Pictures/ItemCrafter/Selection_1")
    @sprites["Cancel_Hov"].x=115
    @sprites["Cancel_Hov"].y=330

    @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
    
    self.openItemCrafterscene
  end
  
  def openItemCrafterscene
    self.CheckAbleToCraft
    pbFadeInAndShow(@sprites) {self.text}
    self.input
    self.action
  end
  
  def closeItemCrafterscene
    pbFadeOutAndHide(@sprites)  
  end
    
    def input
      case @select
      when 1
        @sprites["Confirm"].opacity=255
        @sprites["Confirm_Hov"].opacity=0
        @sprites["Cancel"].opacity=0
        @sprites["Cancel_Hov"].opacity=255
        @sprites["Item"].opacity=255
        @sprites["Item_Hov"].opacity=0
      when 2
        @sprites["Confirm"].opacity=0
        @sprites["Confirm_Hov"].opacity=255
        @sprites["Cancel"].opacity=255
        @sprites["Cancel_Hov"].opacity=0
        @sprites["Item"].opacity=255
        @sprites["Item_Hov"].opacity=0
      when 3
        @sprites["Confirm"].opacity=255
        @sprites["Confirm_Hov"].opacity=0
        @sprites["Cancel"].opacity=255
        @sprites["Cancel_Hov"].opacity=0
        @sprites["Item"].opacity=0
        @sprites["Item_Hov"].opacity=255
        @sprites["Item_icon"].setBitmap(pbItemIconFile(getID(PBItems,RECIPES[@item][0])))
        if $game_variables[CRAFTVAR][@item]
            @sprites["unknown"].opacity=0
            @sprites["Item_icon"].opacity=255
            @sprites["Item_1_icon"].setBitmap(RECIPES[@item][2]? pbItemIconFile(getID(PBItems,RECIPES[@item][2][0])) : "") # Vendily
            @sprites["Item_2_icon"].setBitmap(RECIPES[@item][3]? pbItemIconFile(getID(PBItems,RECIPES[@item][3][0])) : "") # Vendily
            @sprites["Item_1_icon"].opacity= RECIPES[@item][2] ? 255 : 0
            @sprites["Item_2_icon"].opacity=RECIPES[@item][3] ? 255 : 0
            @mat1=RECIPES[@item][2]? RECIPES[@item][2][0] : -1
            @mat2=RECIPES[@item][3]? RECIPES[@item][3][0] : -1
            @cost1=RECIPES[@item][2]? RECIPES[@item][2][1] : 0
            @cost2=RECIPES[@item][3]? RECIPES[@item][3][1] : 0
            @amount=RECIPES[@item][1]
          else
            @sprites["unknown"].opacity=255
            @sprites["Item_icon"].opacity=0
            @sprites["Item_1_icon"].opacity=0
            @sprites["Item_2_icon"].opacity=0
          end
          self.text
          
        # When pressing Right
        if Input.trigger?(Input::RIGHT)  && @item < RECIPES.length-1
          @item+=1
        elsif Input.trigger?(Input::RIGHT)  && @item ==RECIPES.length-1 # Make it run though the selection after last item.
          @item = 0
        end
        if Input.trigger?(Input::LEFT) && @item >0
          @item-=1
        elsif Input.trigger?(Input::LEFT) && @item ==0 # Make it run though the selection after first item.
          @item = RECIPES.length-1
        end
      end    
      # When pressing Left.
      if Input.trigger?(Input::UP)  && @select <3
        @select+=1
      end
      if Input.trigger?(Input::DOWN) && @select >1
        @select-=1
      end
      
      if Input.trigger?(Input::C) 
        case @select
        when 2 
          if $game_variables[CRAFTVAR][@item]
            if $PokemonBag.pbQuantity(@mat1)<@cost1 || (@mat2!=-1 && $PokemonBag.pbQuantity(@mat2) <@cost2) #Seth Edited 
              Kernel.pbMessage(_INTL("Unable to craft item, you do not meet the required materials"))
            else
              $PokemonBag.pbStoreItem(RECIPES[@item][0],@amount)
              $PokemonBag.pbDeleteItem(@mat1,@cost1)
              if @mat2!=-1
                $PokemonBag.pbDeleteItem(@mat2,@cost2)
              end
              self.text
              Kernel.pbMessage(_INTL("{1} {2}'s were crafted", @amount, PBItems.getName(getID(PBItems,RECIPES[@item][0]))))
            end
          else
            Kernel.pbMessage(_INTL("You do not know this items recipe"))
          end
        when 1
          @close=@select
          self.closeItemCrafterscene
        end       
      end
      
      if Input.trigger?(Input::B)
        @close=@select
        self.closeItemCrafterscene  
      end
      
    end
    
  def action
    while @close==0
      Graphics.update
      Input.update
      self.input
    end
  end
  
  def text
    overlay= @sprites["overlay"].bitmap
    overlay.clear
    baseColor=Color.new(255, 255, 255)
    shadowColor=Color.new(0,0,0)
    pbSetSystemFont(@sprites["overlay"].bitmap)
    textos=[]
    if $game_variables[CRAFTVAR][@item]
      @text1=_INTL("{1}/{2} - {3}", $PokemonBag.pbQuantity(@mat1),@cost1, PBItems.getName(getID(PBItems,@mat1)))
      if @mat2==-1
        @text2=_INTL("")
      else
        @text2=_INTL("{1}/{2} - {3}", $PokemonBag.pbQuantity(@mat2),@cost2 , PBItems.getName(getID(PBItems,@mat2)))
      end
    else
      @text1=_INTL("UNKOWN")
      @text2=_INTL("UNKOWN")
    end
    @text3=_INTL("{1} / {2}", @item + 1, RECIPES.length)
    textos.push([@text1,175,115,false,baseColor,shadowColor])
    textos.push([@text2,175,198+5,false,baseColor,shadowColor])
    textos.push([@text3,75,30,false,baseColor,shadowColor])
    textos.push(["Craft",230,280+5,false,baseColor,shadowColor])
    textos.push(["Cancel",230,330+5,false,baseColor,shadowColor])
    pbDrawTextPositions(overlay,textos)
  end
  
  def CheckAbleToCraft
    if $game_variables[CRAFTVAR][0]
      @sprites["Item_icon"].opacity=255
      @sprites["Item_1_icon"].opacity=255
      @sprites["unknown"].opacity=0
    else
      @sprites["Item_icon"].opacity=0
      @sprites["Item_1_icon"].opacity=0
      @sprites["unknown"].opacity=255
    end
  end
  
    
end
 
Last edited:
8
Posts
4
Years
  • Age 30
  • Seen Jan 12, 2022
Since you can make crafting recipe's unlockable, how exactly would i go about making it where after doing certain in-game tasks (ie defeating a gym or simply just talking to an npc) it unlocks a certain recipe?
 
30
Posts
6
Years
Since you can make crafting recipe's unlockable, how exactly would i go about making it where after doing certain in-game tasks (ie defeating a gym or simply just talking to an npc) it unlocks a certain recipe?

After that event just add:

$game_variables[CRAFTVAR][x]=true # 'x' being the item index (remember start counting from 0 ie 0 is first item, 1 is second etc etc)
 
Last edited:
Back
Top