New account registration is temporarily disabled.

[SCRIPTING] [RMXP] ONGOING TOOLBELT PROBLEMS, UPDATES

Posts

Pages: 1
Progress...
I was getting a no method error for next_tool.
Fixed that by changing the definition to "def self.next_tool".

Then it said weapon_id was undefined.
Turns out "$game_party.actors.weapon_id = @tool" is invalid.
I had to change it to "$game_party.actors.equip(0, @tool)".


Currently:
Now the whole thing runs without errors, but nothing seems to happen.


You may notice I have not actually implemented the key ingredient: the L/R button activation. I've done that before with run scripts, so I'm more trying to get the rest of the functionality in place before I polish that up. For now it's just being called from an event.

Toolbelt module is currently after the changes to game_actor and _scene equip.
It has it's own heading block.

#By Triangle Games Master, as TriangleGM on rpgmaker.net
#
#ALTERS EXISTING: (including comments)
#Game_Actor: lines 36, 71-72
#Scene_Equip: lines 112-115
#
#==============================================================================
# ** Toolbelt
#------------------------------------------------------------------------------
# This script includes a re-write and original script.
# It is an inter-working part of the Crop Farming Toolkit.
# It references element 17 as set on the system tab of the database.
# It allows players to cycle through equipping tools from the map.
# The last non-tool weapon equipped is added to the toolbelt.
# Current Weapon variable (@current_w) added to Game_Actor.
# Toolbelt refresh in Scene_Equip.
# New module Toolbelt begins at line 128.
#==============================================================================

class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :name # name
attr_reader :character_name # character file name
attr_reader :character_hue # character hue
attr_reader :class_id # class ID
attr_reader :weapon_id # weapon ID
attr_reader :armor1_id # shield ID
attr_reader :armor2_id # helmet ID
attr_reader :armor3_id # body armor ID
attr_reader :armor4_id # accessory ID
attr_reader :level # level
attr_reader :exp # EXP
attr_reader :skills # skills
attr_reader :current_w # last real weapon equipped

#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_name = actor.character_name
@character_hue = actor.character_hue
@battler_name = actor.battler_name
@battler_hue = actor.battler_hue
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
@hp = maxhp
@sp = maxsp
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
#ADDED current weapon
@current_w = 0
# Learn skill
for i in 1..@level
for j in $data_classes[@class_id].learnings
if j.level == i
learn_skill(j.skill_id)
end
end
end
# Update auto state
update_auto_state(nil, $data_armors[@armor1_id])
update_auto_state(nil, $data_armors[@armor2_id])
update_auto_state(nil, $data_armors[@armor3_id])
update_auto_state(nil, $data_armors[@armor4_id])
end
end

class Scene_Equip
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
#ADDED SCRIPT to refresh toolbelt
if @actor = 0
$toolbelt.new_equip
end
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
end
end
end

#==============================================================================
# ** Toolbelt
#------------------------------------------------------------------------------
# Cycles through available tools while on map screen with L/R buttons.
# Uses the variable @current_w to return to the last equipped non-tool weapon.
# Updates toolbelt if player uses standard equipment menu
#==============================================================================
module Toolbelt

@belt = []
@pocket = 0
@tool = 0

#This sets up the belt array
def refresh
@belt.clear
@belt[0] = $game_party.actors[0].current_w
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
if $data_weapons[i].element_set.include?(17)
@belt.push($data_weapons[i])
end
end
end

#This sets the current pocket based on current tool
for i in 0...@belt.size
if @tool == @belt[i]
@pocket = @belt[i].index
end
end
end

#This keeps current weapon and tool up to date
def new_equip
@tool = $game_party.actors[0].weapon_id
#If the tool is a real weapon, update current weapon
unless $data_weapons[@tool].element_set.include?(17)
$game_party.actors[0].current_w = $game_party.actors[0].weapon_id
end
@refresh
end

#This moves forward one pocket on the belt
def self.next_tool
@refresh
@pocket += 1
@tool = @belt[@pocket]
$game_party.actors[0].equip(0, @tool)
#TO DO: WINDOW TO ALERT PlAYER TO TOOl CHANGE
end
end
Pages: 1