hey guys,
tryin some scripting again, this time just a UI for a macro system im working on.
heres the script
class Window_Macro < Window_Base
def initialize
super(220, 100, 288, 230)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
@actor = $game_party.actors[0]
@phealth = $game_variables[4]
@pforce = $game_variables[5]
self.contents.draw_text(32,0,96,32, "Health Macro")
self.contents.draw_text(32,32,128,32, "#{@phealth} / #{@actor.maxhp}")
draw_bar_beginner(32, 64, @phealth, @actor.maxhp, 192, 10,bar_color = Color.new(150, 0, 0, 255) )
self.contents.draw_text(32,96,96,32, "Force Macro")
self.contents.draw_text(32,128,128,32, "#{@pforce} / #{@actor.maxsp}")
draw_bar_beginner(32,160, @pforce, @actor.maxsp, 192, 10, bar_color = Color.new(0,0,150,255) )
end
end
class Window_Potion < Window_Selectable
def initialize
super (220,160,220,198)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = 0
end
def refresh
self.contents.clear
@item_max = 5
self.contents.draw_text(0,0,96,32, "100")
self.contents.draw_text(0,32,96,32, "250")
self.contents.draw_text(0,64,96,32, "500")
self.contents.draw_text(0,96,96,32, "1000")
self.contents.draw_text(0,128,96,32, "2000")
end
end
class Window_PotionF < Window_Selectable
def initialize
super (220,160,220,198)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = 0
end
def refresh
self.contents.clear
@item_max = 5
self.contents.draw_text(0,0,96,32, "50")
self.contents.draw_text(0,32,96,32, "125")
self.contents.draw_text(0,64,96,32, "250")
self.contents.draw_text(0,96,96,32, "500")
self.contents.draw_text(0,128,96,32, "1000")
end
end
class Scene_Macro
def initialize(menu_index = 0)
@menu_index = menu_index
end
def main
s1 = "Change HP Pots"
s2 = "Change FP Pots"
@command1_window = Window_Command.new(160, [s1, s2])
@command_window.index = @menu_index
end
@macro_window = Window_Macro.new
@potion_window = Window_Potion.new
@potion_window.visible = false
@potionf_window = Window_Potionf.new
@potionf_window.visible = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command1_window.dispose
@macro_window.dispose
@potion_window.dispose
@potionf_window.dispose
end
def update
@command1_window.update
@macro_window.update
@potion_window.update
@potionf_window.update
if @command1_window.active
update_command
return
end
if @potion_window.active
update_potion
return
end
if @potionf_window.active
update_potionf
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0
$game_system.se_play($data_system.buzzer_se)
return
end
case @command1_window.index
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@potion_window.active = true
@potion_window.index = 0
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@potionf_window.active = true
@potion_window.index = 0
end
return
end
def update_potion
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0
$game_system.se_play($data_system.buzzer_se)
return
end
case @potion_window.index
when 1
$game_system.se_play($data_system.decision_se)
$game_variables[4] = 100
$scene = Scene_Macro
when 2
$game_system.se_play($data_system.decision_se)
$game_variables[4] = 250
$scene = Scene_Macro
when 3
$game_system.se_play($data_system.decision_se)
$game_variables[4] = 500
$scene = Scene_Macro
when 4
$game_system.se_play($data_system.decision_se)
$game_variables[4] = 1000
$scene = Scene_Macro
when 5
$game_system.se_play($data_system.decision_se)
$game_variables[4] = 2000
$scene = Scene_Macro
end
return
end
def update_potionf
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0
$game_system.se_play($data_system.buzzer_se)
return
end
case @potionf_window.index
when 1
$game_system.se_play($data_system.decision_se)
$game_variables[5] = 50
$scene = Scene_Macro
when 2
$game_system.se_play($data_system.decision_se)
$game_variables[5] = 125
$scene = Scene_Macro
when 3
$game_system.se_play($data_system.decision_se)
$game_variables[5] = 250
$scene = Scene_Macro
when 4
$game_system.se_play($data_system.decision_se)
$game_variables[5] = 500
$scene = Scene_Macro
when 5
$game_system.se_play($data_system.decision_se)
$game_variables[5] = 1000
$scene = Scene_Macro
end
return
end
end
end
the windows work fine, but then when i put the scene in as well i get an error.
script window_base line 17 no methoderror occured.
undefined method for 'windowskin_name' for Nilclass
since i aint to used to scripting yet im sure there will be others.
im usin XP with blizz abs 1.99 and tons 6.71
thanks
edit.
taking out that end and putting it at the bottom worked, then i noticed a few other errors, sorted those out now and its working,
thanks.
It seems you're calling this window when $game_system isn't defined yet... When are you calling this scene?
EDIT: Sorry, it wasn't the scene. It's a syntax error.
def main
p 'f'
s1 = "Change HP Pots"
s2 = "Change FP Pots"
@command1_window = Window_Command.new(160, [s1, s2])
@command_window.index = @menu_index
end
@macro_window = Window_Macro.new
@potion_window = Window_Potion.new
@potion_window.visible = false
@potionf_window = Window_Potionf.new
@potionf_window.visible = false
Graphics.transition
See that "end" in the middle? That ends the "main" method, so everything after that gets executed when RMXP starts, when there is no $game_system, so it can't get the windowskin name. It's a syntax error, but meybe the number of "end"s got justified somehow and RMXP didn't detect it as a syntax error.
sorry thought id sorted this out,
im trying to disable an item in a window selectable
the window code is
class Window_Potion < Window_Selectable
def initialize
super (260,160,254,254)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.index = 0
end
def refresh
self.contents.clear
@item_max = 7
self.contents.draw_text(0,0,160,32, "Aid Potion +100")
self.contents.draw_text(0,32,160,32, "Aid Potion +250")
self.contents.draw_text(0,64,160,32, "Aid Potion +500")
self.contents.draw_text(0,96,160,32, "Aid Potion +1000")
self.contents.draw_text(0,128,160,32, "Aid Potion +2000")
self.contents.draw_text(0,160,160,32, "Aid Potion +3000")
self.contents.draw_text(0,192,160,32, "Aid Potion +4000")
end
end
i want to check the players items and disable an option if the player doesnt have any of those potions.
i think this will check the items, might be wrong
$game_party.item_number(i) = 0
but i dont know how to disable the option
i treid this
if $game_party.item_number(1) !=0
Window_Potion.disable_item(0)
end
but that doesnt work.
any sugestions?
thanks
I think disable_item is a method in Window_Command, not Window_Selectable. You might have to define the draw_item method.