RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Scripting CMS Problem

0 Members and 1 Guest are viewing this topic.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
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)

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
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.
Code: [Select]
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
  end
Now, 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.
Code: [Select]
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.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
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

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Care to tell us the damn error?

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
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)

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Post all your code.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
allright.

Code: [Select]
#==============================================================================
# ** 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.

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
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
Code: [Select]
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
Code: [Select]
      new_atk = @actor.atk
      new_pdef = @actor.pdef
      new_mdef = @actor.mdef
This 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! ^^;

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
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)

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon