Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Set $game_party.steps to a variable?

Code:
st = $game_variables[299]

$game_party.steps = st
It seems simple, but I guess it doesn't work like that. I'm calling it from an event, so I don't have enough room without the st variable. I'm getting an undefined method error ('steps=').

What am I doing wrong?
 
For whatever crazy reason you might need this... try this instead:
Code:
$game_party.steps = $game_variables[299]
It looks like it should work, however I'm not sure that Game_Party actually has a method called steps... haven't worked with RMXP for a while ^^" Your error definately says that you'Re trying to use a method that's non-existant, so you might check for that.

Either way, the easier way for you would be to find yourself Window_Steps or whatever it's called, and replace the variable drawn with $game_variables[299] - saves you the event that sets this as well. (that's right, events are actually unnecessary for system-ey things ;) )
 
BlueScope":24c08sna said:
For whatever crazy reason you might need this... try this instead:
Code:
$game_party.steps = $game_variables[299]
It looks like it should work, however I'm not sure that Game_Party actually has a method called steps... haven't worked with RMXP for a while ^^" Your error definately says that you'Re trying to use a method that's non-existant, so you might check for that.

Either way, the easier way for you would be to find yourself Window_Steps or whatever it's called, and replace the variable drawn with $game_variables[299] - saves you the event that sets this as well. (that's right, events are actually unnecessary for system-ey things ;) )

Your subtle event bashing makes me smile X3

Your suggestion won't work, sadly. The 'Script...' command only allows a small amount of text on each line.
Code:
$game_party.steps = $game_variables[299]
This goes over the text limit by a single character. Yeah. Makes me want to punch things.

I thought at first that I'd just change the window to display the variable, but I think that would overcomplicate things. The crazy reasoning behind this is that, at the push of a button, the player completely resets the game to a predetermined position. Steps play a large role in the game and definitely need to be reset with the rest of the game's data, most of which is stored in game variables. ;3

EDIT: GAH! I feel so dumb right now. I can't believe that I didn't think to increase $game_variables[299] in Game_Party instead of @steps. :|

Well, it works perfectly now! Rejoice in your triumph, for scripting has won this day!

Thanks, BlueScope XD
 
death by moogles":jvcoonow said:
I can't believe that I didn't think to increase $game_variables[299] in Game_Party instead of @steps. :|
That is exactly what I meant up there ^^

For future event madness, try this in a Call Script:
Code:
$game_party.steps =

$game_variables[299]
I'm not sure if this specific one will work, but it really should... stuff like this works, for example:
Code:
$game_party.steps = 400 +

300 +

200


So much for the 'answering your question' part; here comes the 'take your system, rip it apart, improve it, with MORE SCRIPTING' part ;)
You might be going over this by hand, resetting each and every variable there might be in your scope of important things to reset. What you really want to do is use your already existing save methods, cut them in shape by replacing the file dump methods by variable assignments, and therefore create virtual saves. Doing this, your whole system will maybe take 20 mins to do, give or take, and you will neither have to worry about event anything nor script anything additionally, as everything you'd normally save now becomes reset on button press as well. Of course, you can customize this, if for example you don't want to reset your switches or variables.


Off-topic: Scripting wins every day. Actually, scripting will be running the quarter mile faster than events can run it in their light-n-sound-tuned rice cars. Scripting can also make a half-empty glass half full. Scripting even can take your evented girlfriend from you, however, it won't, as scripting doesn't need to prove it's power over events... or you.
 
If, at the top of Game_Party, you change the line:

attr_reader :steps

to

attr_accessor :steps

then

$game_party.steps = $game_variables[299]

will work.


attr_reader only creates a "steps" method that returns the value of @steps
attr_accessor also creates a "steps=" method that allows you to set the value of @steps
 
Changing standard scripts is only bad if you're developing something to share, that someone else might try to implement and it's important that it doesn't create conflicts with other scripts. If it's just for your own game, and you know what you're doing, changing the scripts should not be a problem.
In fact, I have a couple projects where a bunch of the standard scripts are completely re-written.
 
BlueScope":1qrq79c9 said:
death by moogles":1qrq79c9 said:
I can't believe that I didn't think to increase $game_variables[299] in Game_Party instead of @steps. :|
That is exactly what I meant up there ^^
I misunderstood ;_;

BlueScope":1qrq79c9 said:
For future event madness, try this in a Call Script:
Code:
$game_party.steps =

$game_variables[299]
I'm not sure if this specific one will work, but it really should... stuff like this works, for example:
Code:
$game_party.steps = 400 +

300 +

200
I tried that too. I've had to use the call script command to do things like that, and they'd always worked, but it didn't work this time. I guess it's because of what Brewmeister said.

BlueScope":1qrq79c9 said:
So much for the 'answering your question' part; here comes the 'take your system, rip it apart, improve it, with MORE SCRIPTING' part ;)
You might be going over this by hand, resetting each and every variable there might be in your scope of important things to reset. What you really want to do is use your already existing save methods, cut them in shape by replacing the file dump methods by variable assignments, and therefore create virtual saves. Doing this, your whole system will maybe take 20 mins to do, give or take, and you will neither have to worry about event anything nor script anything additionally, as everything you'd normally save now becomes reset on button press as well. Of course, you can customize this, if for example you don't want to reset your switches or variables.
I actually thought about this before I started the system, but I have no idea how I'd do it. The system is completely finished and it runs fine. I don't need to reset EVERYTHING. There are about twelve values that have to be reset; the game is extremely simple. Honestly, I'd love to do it this way, because it just seems so much easier. I just don't know how or where to start learning. I do, however, know how to do it with events, so that's what I did.


Off-topic: stfu <3

Brewmeister":1qrq79c9 said:
If, at the top of Game_Party, you change the line:

attr_reader :steps

to

attr_accessor :steps

then

$game_party.steps = $game_variables[299]

will work.


attr_reader only creates a "steps" method that returns the value of @steps
attr_accessor also creates a "steps=" method that allows you to set the value of @steps
Ah! I've wondered what the difference was, but it's never been of any consequence in anything that I've done, so I never thought to look into it. Thanks a lot!

So, from context, I've come to the conclusion that attr_accessor is basically just attr_reader and attr_writer in one go. Is that correct?
 
Changing standard scripts is only bad if you're developing something to share, that someone else might try to implement and it's important that it doesn't create conflicts with other scripts. If it's just for your own game, and you know what you're doing, changing the scripts should not be a problem.
In fact, I have a couple projects where a bunch of the standard scripts are completely re-written.
One problem is, that you might confuse lines if you change too much of the standard scripts. Whenever it says "add this code after line X" you have to check what line X is in the original script and where it is now in yours.
Second problem is, that if another script you use overwrites the changed method, your changes become useless.

Of course, both of that problems can't appear if you only change one line, like here, but anyway, you shouldn't habituate that way of editing stuff. You should use alias whenever you can.
 
On the changing-default-scripts vs aliasing method: For scripts that are meant to be shared, one would obviously have to alias or outsource (lol at the hidden (?) pun) all code possible. For a project, however, you should end up with no aliasing that's unnecessary, which should in most cases be all of your aliases. However, as Bahamut said, you might work with aliases for the time being to keep a nice overview, for example to sort script snippets into function categories.
Well, my opinion on the thing...

@moogles: What can I say... just because something is working doesn't mean it's good, or even fine (event systems are a good example :tongue: okay, I'll stop). When scripting, especially with RPG Maker programs that have horrible Interpreters, you always wanna go for the maximum performing outcome. Otherwise, you don't really need to start scripting at all. Code that's less perfect than it could be, with the creator knowing and accepting that, is not even worth the light needed to emit it from your monitor, as all you'll have then is an event script.
To give you a practical example - I've been working on quite a complex script for the last week give or take, and while the core contents isn't more than 200 lines, I've rewritten the whole thing more than 3 times now, and of course fixed parts of it uncounted times. On top of that, it's a script running in a Gosu interface, meaning I wouldn't actually need to improve it, as Gosu has lightning-fast bitmap drawing... but guess what, I did. You may say I wasted my time, but I say I have a script, while you have a bunch of lines ^^

As for the save-like method... just look at the respective methods in... I think Scene_File? It should be a fairly easy thing for a beginner to do if you're ready to put some time into figuring out the various things you can do. Since you were talking about you don't know where to start; it's actually pretty simple: learn from the default scripts, try to modify them not necessarily in a useful or new, but highly functional and intelligent manner. Take a document such as Programming Ruby (Built-in Classes and Methods section is especially useful) on your lone island, and just go from there. There's no specific order in which you'll have to learn things, but personally, I think you'll have it easier later on if you care about performance, scripting style and documentation of your scripts from the start..
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top