FL
Pokémon Island Creator
- 2,507
- Posts
- 14
- Years
- Seen Jan 15, 2025
Essentials has the feature of register a item with a key (F5). This tutorial explain how to add more keys simultaneous. In this example I gonna add F4 and F3, but I teach how to add others.
At PSystem_Controls script section
As F4 and F3 aren't mapped in input, we need to map. Before line
add
The order doens't matter if is in the "case" statement. The 0x72 and 0x73 are the F3/F4 codes in keyboard (there's a list here). Before line:
add
The order and the code doens't matter if they are in the module Input. Just make sure that the numbers (31 and 32) aren't the same as other constants in this module. If the F3 and F4 keys are mapped, we don't have to do the two above code changes. Before line
add
These two arrays store all the key that you can register items. If you wish to add more keys, just include in these two arrays, map in input (if the keys aren't mapped) and add an icon. Note about keys that do other things, so if you add the F8 (button that take screenshots) every time that you hits F8 you take a screenshot AND do the effects of a registered key.
The picture that appears at right of the item name at bag is named bagRegX.png in folder Graphics\Pictures, where X is the array index starting in 0, so in this example we need the bagReg0.png (F5), bagReg1.png (F4) and bagReg2.png (F3).
At Scene_Map script section
Change:
to
Change
to
At PField_Field script section
Change
to
At PField_Metadata script section
Change
to
At PScreen_Bag script section
Change
to
Change
to
Change
to
Change
to
Change
to
Change
to
Change
to
At PSystem_Controls script section
As F4 and F3 aren't mapped in input, we need to map. Before line
Code:
when Input::F5
add
Code:
when Input::F3
return [0x72] # F3
when Input::F4
return [0x73] # F4
The order doens't matter if is in the "case" statement. The 0x72 and 0x73 are the F3/F4 codes in keyboard (there's a list here). Before line:
Code:
F5 = 25
add
Code:
F3 = 31
F4 = 32
The order and the code doens't matter if they are in the module Input. Just make sure that the numbers (31 and 32) aren't the same as other constants in this module. If the F3 and F4 keys are mapped, we don't have to do the two above code changes. Before line
Code:
LeftMouseKey = 1
add
Code:
ITEMKEYS = [Input::F5,Input::F4,Input::F3]
ITEMKEYSNAMES = [_INTL("F5"),_INTL("F4"),_INTL("F3")]
These two arrays store all the key that you can register items. If you wish to add more keys, just include in these two arrays, map in input (if the keys aren't mapped) and add an icon. Note about keys that do other things, so if you add the F8 (button that take screenshots) every time that you hits F8 you take a screenshot AND do the effects of a registered key.
The picture that appears at right of the item name at bag is named bagRegX.png in folder Graphics\Pictures, where X is the array index starting in 0, so in this example we need the bagReg0.png (F5), bagReg1.png (F4) and bagReg2.png (F3).
At Scene_Map script section
Change:
Code:
if Input.trigger?(Input::F5)
unless pbMapInterpreterRunning?
$PokemonTemp.keyItemCalling = true if $PokemonTemp
end
end
to
Code:
unless pbMapInterpreterRunning?
for keyNumber in 0...Input::ITEMKEYS.size
if Input.trigger?(Input::ITEMKEYS[keyNumber]) && $PokemonTemp
$PokemonTemp.keyItemCalling = keyNumber
end
end
end
Change
Code:
$PokemonTemp.keyItemCalling=false
$game_player.straighten
Kernel.pbUseKeyItem
to
Code:
$game_player.straighten
Kernel.pbUseKeyItem($PokemonTemp.keyItemCalling)
$PokemonTemp.keyItemCalling=nil
At PField_Field script section
Change
Code:
def pbUseKeyItem
if $PokemonBag.registeredItem==0
Kernel.pbMessage(_INTL("A Key Item in the Bag can be registered to this key for instant use."))
else
Kernel.pbUseKeyItemInField($PokemonBag.registeredItem)
end
end
to
Code:
def pbUseKeyItem(itemKeyNumber)
if $PokemonBag.registeredItem[itemKeyNumber]==nil
Kernel.pbMessage(_INTL("A Key Item in the Bag can be registered to this key for instant use."))
else
Kernel.pbUseKeyItemInField($PokemonBag.registeredItem[itemKeyNumber])
end
end
At PField_Metadata script section
Change
Code:
@keyItemCalling = false
to
Code:
@keyItemCalling = nil
At PScreen_Bag script section
Change
Code:
if @[email protected][self.pocket][index][0]
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/bagReg",rect.x+rect.width-58,ypos+4,0,0,-1,-1]
])
end
to
Code:
i = @bag.registeredItem.index(@bag.pockets[self.pocket][index][0])
if i
pbDrawImagePositions(self.contents,[
[sprintf("Graphics/Pictures/bagReg#{i}"),rect.x+rect.width-58,ypos+4,0,0,-1,-1]
])
end
Change
Code:
attr_reader :registeredItem
to
Code:
def registeredItem
# The below line is to this change don't mess with existing saves
@registeredItem = [@registeredItem] if [email protected]_a?(Array)
while @registeredItem.size<Input::ITEMKEYS.size
@registeredItem.push(nil)
end
return @registeredItem
end
Change
Code:
@registeredItem=0
to
Code:
@registeredItem=[]
Change
Code:
def pbRegisterKeyItem(item)
if item.is_a?(String) || item.is_a?(Symbol)
item=getID(PBItems,item)
end
if !item || item<1
raise ArgumentError.new(_INTL("The item number is invalid."))
return
end
@registeredItem=(item!=@registeredItem) ? item : 0
end
to
Code:
def pbRegisterKeyItem(item,itemKeyNumber)
if item.is_a?(String) || item.is_a?(Symbol)
item=getID(PBItems,item)
end
if !item || item<1
raise ArgumentError.new(_INTL("The item number is invalid."))
return
end
index = registeredItem.index(item)
registeredItem[index]=nil if index # remove duplicates
registeredItem[itemKeyNumber]=item if !index || index!=itemKeyNumber
end
Change
Code:
@registeredItem=0 if @registeredItem==item && !pbHasItem?(item)
to
Code:
index = registeredItem.index(item)
registeredItem[index]=nil if index && !pbHasItem?(item)
Change
Code:
if @bag.registeredItem==item
commands[cmdRegister=commands.length]=_INTL("Deselect")
elsif pbIsKeyItem?(item) && ItemHandlers.hasKeyItemHandler(item)
commands[cmdRegister=commands.length]=_INTL("Register")
end
to
Code:
commands[cmdRegister=commands.length]=_INTL("Register") if pbIsKeyItem?(item) && ItemHandlers.hasKeyItemHandler(item)
Change
Code:
@bag.pbRegisterKeyItem(item)
to
Code:
registerCommands = Input::ITEMKEYSNAMES + [_INTL("Back")]
registerCommand = @scene.pbShowCommands(
_INTL("Choose a key.",itemname),registerCommands)
@bag.pbRegisterKeyItem(item,registerCommand) if registerCommand!=-1 && registerCommand!=registerCommands.size
Attachments
Last edited: