Lawrence 0 Report post Posted June 26, 2014 (edited) Hi everyone, I'm new in RGSS scripting and I really need help. I searched in the forum, I searched on google, I searched in the rpgmakerXP guide, but I can't find anything... Also lot of RPGXP script tutorial in this forum have broken links :( Here's one of the problems class Stamina_drain def initialize if $game_switches[4] == true if $game_variables[5] > 0 $game_variables[5] -= 1 end else if $game_variables[5] < $game_variables[6] $game_variables[5] += 1 end end end end It's a script I made to drain stamina (variable 5) when running. It works but I'm trying to drain (and refill) the stamina value slower and I can't find anywhere how should I write the command "wait"... Also, does exist a simple list of event commands translated in script commands? That will be very useful because I can't understand a single thing in the XPGuide... Can you help me?Thank you Edited June 26, 2014 by Lawrence Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 Ok, I have read all the things in the guide, game library... Built-in classes, functions... And I can't find how to slow down the check time. I don't want that function to check every frame but (at least) How can I do that? I could do that by a common event that calls the script but what's the point of making a script if I can't figure how to add a simple (simple?) thing like a wait command? Please someone can help me? And (yeah, it sounds stupid but) am I in the right section for asking help? Share this post Link to post Share on other sites
black mage 28 Report post Posted June 27, 2014 (edited) if @timer > 0 @timer -= 1 else something happened that trigger the script. end Something like that, perhaps? I'm not sure myself, but I think that's how it'll works. Edited June 27, 2014 by black mage Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 if @timer > 0 @timer -= 1 else something happened that trigger the script. end Something like that, perhaps? I'm not sure myself, but I think that's how it'll works. Thanks I'll check immediately Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 if @timer > 0 @timer -= 1 else something happened that trigger the script. end Something like that, perhaps? I'm not sure myself, but I think that's how it'll works. Should be something like that? class Stamina_drain def initialize if @timer > 0 #timer @timer -= 1 else if $game_switches[4] == true if $game_variables[5] > 0 case Input.dir4 when 1 .. 4 $game_variables[5] -= 1 end end else if $game_variables[5] < $game_variables[6] $game_variables[5] += 1 end end end #timer end end end Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 if @timer > 0 @timer -= 1 else something happened that trigger the script. end Something like that, perhaps? I'm not sure myself, but I think that's how it'll works. Anyway it doesn't work, stamina variable doesn't go down... But... Does a wait script command exist at all? :S Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 if @timer > 0 @timer -= 1 else something happened that trigger the script. end Something like that, perhaps? I'm not sure myself, but I think that's how it'll works. Ah but this controls the timer! Sorry, I think I didn't explain myself ^^"" I meant a command that should make the script wait, like the event command "wait: n frame(s)" Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 I think (I think) there must be something similar of what I need on the window_playtime script... I see what I can get from there Share this post Link to post Share on other sites
Saltome 16 Report post Posted June 27, 2014 (edited) The thing is rgss1 isn't a very good library. I find myself struggling against the choices the developers made when making it more than the choices I've made in whatever I'm trying to make. Integrating code and third party scripts into the structure of the native system is a nightmare, a minefield of nasty bugs. To answer your question, no. There is a list of methods that are called when processing events, the problem is they are designed to work within the events. So to be able to use a command event inside a script you have to understand how that specific command works, and for the most part it's easier to just take the code you need from the command and copy it to your own script. Now to the point at hand, I'd rethink the whole idea. You want to make it so movement drains stamina, correct? First, you have to pick a location where it would be most convenient to put your code. Since the movement code for the player is handled by the Game_Player I'd say to put the code in there. Try doing this: Game_Player line 10: We need a new variable that will hold the stamina value, and it should be accessible from outside the player object. attr_accessor :stamina Game_Player line 11-14: We need to initialize the value of @stamina to prevent it from crashing the game. def initialize super #This calls the initialize method of Game_Character. @stamina=10 #Starting value. end Game_Player line 220: Here is where the program tells the player event to move when the direction keys are pressed. We need to tell it to reduce stamina, and print out the new value. case Input.dir4 when 2 move_down @stamina-=1 #This reduces stamina by 1 point every time you move(down). p @stamina #This prints out the current stamina. when 4 move_left @stamina-=1 p @stamina when 6 move_right @stamina-=1 p @stamina when 8 move_up @stamina-=1 p @stamina end end ps: you need to add the code that I made darker. Edited June 27, 2014 by Saltome 1 Lawrence reacted to this Share this post Link to post Share on other sites
Lawrence 0 Report post Posted June 27, 2014 (edited) The thing is rgss1 isn't a very good library. I find myself struggling against the choices the developers made when making it more than the choices I've made in whatever I'm trying to make. Integrating code and third party scripts into the structure of the native system is a nightmare, a minefield of nasty bugs. To answer your question, no. There is a list of methods that are called when processing events, the problem is they are designed to work within the events. So to be able to use a command event inside a script you have to understand how that specific command works, and for the most part it's easier to just take the code you need from the command and copy it to your own script. Now to the point at hand, I'd rethink the whole idea. You want to make it so movement drains stamina, correct? First, you have to pick a location where it would be most convenient to put your code. Since the movement code for the player is handled by the Game_Player I'd say to put the code in there. Try doing this: Game_Player line 10: We need a new variable that will hold the stamina value, and it should be accessible from outside the player object. attr_accessor :stamina Game_Player line 11-14: We need to initialize the value of @stamina to prevent it from crashing the game. def initialize super #This calls the initialize method of Game_Character. @stamina=10 #Starting value. end Game_Player line 220: Here is where the program tells the player event to move when the direction keys are pressed. We need to tell it to reduce stamina, and print out the new value. case Input.dir4 when 2 move_down @stamina-=1 #This reduces stamina by 1 point every time you move(down). p @stamina #This prints out the current stamina. when 4 move_left @stamina-=1 p @stamina when 6 move_right @stamina-=1 p @stamina when 8 move_up @stamina-=1 p @stamina end end ps: you need to add the code that I made darker. Thanks, I did in that way (but with a variable instad of @stamina) but the problem is still there: stamina goes down and up by 1 each frame, and I'm trying to make it going down (or up) by 1 each second @_@ Edited June 27, 2014 by Lawrence Share this post Link to post Share on other sites