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.
Help with changing a reference through Call Script command

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 84
Okay, since today's a snowday for me, I've been trying my hand at RGSS to pass the time. I've been working at a window to show the objective in the menu, and it works fine, but I want to know how to make the objective changeable using the Call Script command. I've tried nearly everything I could think of, but nothing has worked.

Here's the script:

Code: [Select]
#==============================================================================
# ** Window_Objective
#------------------------------------------------------------------------------
#  This window displays the party's current objective.
#==============================================================================

  OBJECTIVE = "Make this script work!"

class Window_Objective < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, -20, 100, 70, "Objective:")
    self.contents.font.color = normal_color
    self.contents.draw_text(90, -20, 400, 70, OBJECTIVE)
  end
end

It's probably something stupidly simple I'm missing and/or doing wrong, but since I know very little about RGSS, I have no idea what it could be.
« Last Edit: January 07, 2009, 06:26:43 PM by Parkallooza »

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
I'm not a fan of global variables but this is one case you might try using one. To keep the name of the variable from being an issue, you could try naming it something like $parkallooza_objective. Then just use the Call Script command to change the contents of your global variable.

The same thing may work with public variables as well. Public variables are @variable_types.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Yeah, I would suggest something similar. I would edit one of the Game_ classes such as Game_System like so:

Code: [Select]
class Game_System
  attr_accessor :current_objective
  alias prklza_init_obj_var_98n3 initialize
  def initialize
    prklza_init_obj_var_98n3
    @current_objective = "Make this script work!"
  end
end

and then I would just draw $game_system.current_objective in your window. You could change it with a call script: $game_system.current_objective = "". I wouln't put it in it's own global variable because then you'd have to edit Scene_Save and Scene_Load to ensure it is properly saved and loaded. Aside from which, it's a good idea not to have too many global variables floating around.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Thank you for the added knowledge MA. I haven't done scripting in about 6 months or so...so yea, I'm rusty. Modern's idea is much more efficient so I suggest using it.

**
Rep: +0/-0Level 84
Thanks, mates! I think I tried something like that before, but maybe I did it wrong... Oh well, I'm at school so I'll try it out when I get home. Thanks again!