I'm re-arranging stuff for a CMS of my own (trying to learn to script)
I'm having paroblem with the EquipLeft Window.
I'm trying to display the character's other stats (beside just ATK, PDEF and MDEF) I want to display strength and stuff.
but the problem I'm having is this
@new_str = new_str is called an error, when @new_atk = new_atk isn't and I basically copied pasted and renamed stuff
(it displays the present strength, just not the new one during the equip phase)
what did I miss?
(I hope you understood what I ment of course)
That's quite simple. The variable new_str is a nil value until you store something in it. You can't make nil into a text string. In case you didn't know, nil is a non-existant value aka something that doesn't exist. Hence, the error you're getting. If I lose you somewhere along the way of the following explanations or you're still unclear on a few things, don't hesitate to ask more questions okay?
Time to teach you how to do some things. Now lets see...where does @new_atk and new_atk get defined? Easy. Right here.def set_new_parameters(new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
refresh
end
endNow, how does one find where this method is used? Copy "set_new_parameters" but minus the quotation marks. Press Ctrl+Shift+F to do a search through every single script in this project. Paste "set_new_parameters" inside the search box and it'll search for "set_new_parameters" in every script you have in that project. You'll see it found two entries inside Scene_Equip. Check into them!
Now for a short explaination on method inheritance. When you define a method inside a class, you can call it inside other classes. You can also pass off variables when you call a method. When you do this, they are called "arguments". It looks something like this. The method "set_new_parameters" in Window_Equipleft and how it's used in Scene_Equip is a perfect example though of how this works.
class Foo < Window_Base
def initialize
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
end
def foo(arg1, arg2)
self.contents.clear
self.contents.draw_text(200, 64, 36, 32, arg1.to_s, 2)
self.contents.draw_text(200, 64, 36, 32, arg2.to_s, 2)
end
end
class Bar
def main
Foo.foo(2, 10)
end
end
Also, I attached a Scene Generator to this post. It was made by DubeAlex from Creation Asylum and it is fairly useful when you want to lay out a scene ahead of time. Just read the instructions and you'll be able to use it. I use it any time I make a scene for any sort of projects because I can see what the scene will look like ahead of time and there won't be any guess work towards how the scene looks over all.
thanks for the help, but I really didn't need the basic scripting info. ;D
see in, set_new_parameters, that's where the error is coming from
during that method I have @new_str = new_str and that's the line that gives me that error.
I'll try out the scene generator though thanks
Care to tell us the damn error?
undefined local variable of method new_str for #<Window_EquipLeft:02cc9b58>
ok, I understand what it's saying, but where sould I define new_str
(not @new_str)
Post all your code.
allright.
#==============================================================================
# ** Window_EquipLeft
#------------------------------------------------------------------------------
# This window displays actor parameter changes on the equipment screen.
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 270,413)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 4, 30)
draw_actor_graphic(@actor, 175, 45)
draw_actor_parameter(@actor, 4, 60, 0)
draw_actor_parameter(@actor, 4, 90, 1)
draw_actor_parameter(@actor, 4, 120, 2)
draw_actor_parameter(@actor, 4, 150, 3)
if @new_atk != nil
self.contents.font.color = Color.new(0, 255,0,192)
self.contents.draw_text(170, 60, 20, 32, "¦¦", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 60, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = Color.new(0, 255,0,192)
self.contents.draw_text(170, 90, 20, 32, "¦¦", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 90, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = Color.new(0, 255,0,192)
self.contents.draw_text(170, 120, 20, 32, "¦¦", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 120, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = Color.new(0, 255,0,192)
self.contents.draw_text(170, 150, 20, 32, "¦¦", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 150, 36, 32, @new_str.to_s, 2)
end
end
#--------------------------------------------------------------------------
# * Set parameters after changing equipment
# new_atk : attack power after changing equipment
# new_pdef : physical defense after changing equipment
# new_mdef : magic defense after changing equipment
# new_str : strength after changing equipment
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
refresh
end
end
end
I'm basicallyl learning by modding the already existing scripts so gimme a break if I did something really obviously stupid.
I knew it. You didn't add to the list of arguments at "def set_new_parameters(new_atk, new_pdef, new_mdef)". The reason you're getting this error is because new_atk, new_pdef, and new_mdef are arguments passed on from Scene_Equip when the method, set_new_parameters, is called. Also, new_atk etc. are defined variables in Scene_Equip as well.
line 116 of Scene_Equip
set_new_parameters(new_atk, new_pdef, new_mdef)This is where you want to go to add new arguments such as strength to "set_new_parameters".
line 108-110
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdefThis is where you'll find new_atk etc. defined. That should be enough hints to help you out. I believe people learn better by learning things on their own with only a little help from others. This don't mean I'm not willing to help you though! If that were the case, I wouldn't even be posting this! ^^;
oh crap!
that was a stupid simple error that I should have rememberd
it's like classes in java,
I forgot to add that in the method call.
thanks for pointing out that (I make the dumbest errors sometimes :P)