figment68 0 Report post Posted October 11, 2009 I'll try to explain what it is that I am trying to accomplish by giving an example. I want a feature in my game where if a player is inactive (as in not pressing any keys/buttons or moving) for a given period of time then the actor sprite would change to one showing the actor as bored or falling asleep etc. I have created my own sprites and am familiar with switches, events and learning scripting and so forth but was asking for any advice or ideas as to a way to achieve this? Any input would be greatly appreciated. Thanx in advance. Share this post Link to post Share on other sites
Kiriashi 117 Report post Posted October 11, 2009 Ah, like in harvest moon or something? I can't think of anything at the moment... but I will ponder :lol:. Share this post Link to post Share on other sites
figment68 0 Report post Posted October 11, 2009 Ah, like in harvest moon or something? I can't think of anything at the moment... but I will ponder :lol: . Yeah. Or like Sonic or a number of other games. I accomplished it a long time ago with code in a completely different engine however. My wheels are spinning trying to implement the same effect using RMXP. Share this post Link to post Share on other sites
Tomo2000 60 Report post Posted October 11, 2009 Hmm... I'm not too sure on how to make it if somebody hasn' pressed a key in a while but I do know the script line to check if a certain key is being pressed. Input.trigger?(Input::Z) To add that to an event just go into that event, go to the 3rd tab, click on Script and copy and paste that in. You will have to replace Z because otherwise it will check if Z is being pressed or anything that has been set as the equivelant to Z. Share this post Link to post Share on other sites
figment68 0 Report post Posted October 12, 2009 Hmm... I'm not too sure on how to make it if somebody hasn' pressed a key in a while but I do know the script line to check if a certain key is being pressed. Input.trigger?(Input::Z) To add that to an event just go into that event, go to the 3rd tab, click on Script and copy and paste that in. You will have to replace Z because otherwise it will check if Z is being pressed or anything that has been set as the equivelant to Z. Yeah, well that alone isn't going to be able to do it. I am sure that it is going to take some scripting however, and thinking in terms of code before I am going to be able to pull this off efficiently. I will ponder on the matter and look around the scripting resources that I have. Share this post Link to post Share on other sites
zane203 8 Report post Posted October 12, 2009 ok, i just thought of this in the last 5 seconds =o, and is only a THEORY you can create a variable that is timed to increase like a loop of 20 frames = +1 for the variable. no if that variable = 30 (i.e. 30 seconds / or i think 600 frames?) : change actor's graphic, set move route, change player through the graphics you want =D and have it set up as a conditional branch so that when else: button is pressed, set variable back to 0 ^_^ im not good at explaining things but i hope you can get the gist of what im saying. in my head, the theory sounds easy, to set up, but annoying to get everything timed correctly =3 -good luck- Share this post Link to post Share on other sites
Tomo2000 60 Report post Posted October 12, 2009 I like the idea. Might actually work, too. Just the whole "when button is pressed" thing bugs me. I'm not too sure if there is a universal code that says "When any buttion is pressed". You might have to ask Leon about that one. But most things that may appear to have scripting can just, simply, have a few lines in an event, just like Zane has just proved to us. I would be glad to make the event for you if somebody could find that single line of code for "Any button is pressed". I'll do a few tests and take a look around, also. Share this post Link to post Share on other sites
zane203 8 Report post Posted October 12, 2009 i dont mean a universal lol, i mean you're gonna have to put every key that effects movement =3 just left down up and right, and the action button lol, unless you have a turn/jump system lol. i dont know about the possible lag though, anytime you have a variable to keep track, depending on how you check it, depends on how much lag the game will have x.X i learned that the hard way lol =3 Share this post Link to post Share on other sites
Kiriashi 117 Report post Posted October 12, 2009 I like your theory mate! I could never get conditional branches with buttons pressed to work, but that seems like it should work. Share this post Link to post Share on other sites
figment68 0 Report post Posted October 12, 2009 i dont mean a universal lol, i mean you're gonna have to put every key that effects movement =3 just left down up and right, and the action button lol, unless you have a turn/jump system lol. i dont know about the possible lag though, anytime you have a variable to keep track, depending on how you check it, depends on how much lag the game will have x.X i learned that the hard way lol =3 Thanks to every one for their input. I have been brain storming and I came to the same conclusion as far as using a common event and then check every key that effects movement. I will see about throwing something together along these lines today/tonight and will keep you posted as far as my success or failure in achieving this. I think it would be a kewl lil' feature for an RMXP game. I already have most of my NPCs set up to do random things while waiting to be interacted with (such as Orc picking his nose) and I think it will give the over all game play a more fluid feel if the main character behaved similarly when left on it's own. So it looks like a combination of a common event, an event to trigger common event, checking keys and variables are the required parts, now to combine them together in a working fashion. Let me know if any one else has any luck. Share this post Link to post Share on other sites
Raiku44 0 Report post Posted October 17, 2009 there is a very very simple solution to this.. why has no one mentioned it already?!??!?!?!? CONDITIONAL BRANCHES!!!-- COMMON EVENTS!! can you operate these two things? if yes then me just mentioning them two things will hopefully make the picture pop into your head automatically.. HOWEVER if you still are a little confused i'll go into a little bit of detail. Ok.. first of all.. make a COMMON EVENT and call it "check for no keys" or something like that and set it to activate when a switch is activated. the event should try to look something like this! @>Conditional branch: the down button is being pressed OK how exactly does this work? @> Simple. If the player ISN'T pressing DOWN : Else then it will check if he is pressing UP @>Conditional Branch: the UP button is being pressed If he isn't pressing up (set in the else handler) : Else then it will check if he is pressing the next key. @>"PUT YOUR REWARD HERE" HOWEVER! if the player is pressing a button at all the system doesn't work. the method i have used should work 100% flawlessly.. to activate the system create an event on one of your maps (WHERE YOU WANT THE GAME TO DETECT THE BUTTON PRESSES) and make that event activate the "common event" switch that we set earlier. Problem solved i hope! ;) Share this post Link to post Share on other sites
Derek 3 Report post Posted October 18, 2009 That doesn't help him with his time problem though ... I do believe there is an easier way than that also Raiku ... I have a solid idea for an event system that will complete this task. If none of the aforementioned tasks work for you, please PM me, and I will whip the system up along with a DEMO an post it here. Share this post Link to post Share on other sites
Raiku44 0 Report post Posted October 18, 2009 ... replace the "reward here" part with a "set variable" and add 1 to said variable then wait 20 frames @> Control Variables: [xxx- TIME] +=1@> Wait: 20 Frames then you can set a conditional branch that's prerequiste is aforementioned variable = 20Place your reward under this and in the ELSE handler put this: @>Conditional branch: the down button is being pressed OK how exactly does this work?@> Simple. If the player ISN'T pressing DOWN: Else then it will check if he is pressing UP@>Conditional Branch: the UP button is being pressed If he isn't pressing up (set in the else handler): Else then it will check if he is pressing the next key. and so on and so forth.it should look like this: @>conditional branch: Variable [xxx: TIME]==20 @> ""INSERT YOUR REWARD HERE"" :Else @>Conditional branch: the down button is being pressed OK how exactly does this work? @> Simple. If the player ISN'T pressing DOWN : Else then it will check if he is pressing UP @>Conditional Branch: the UP button is being pressed If he isn't pressing up (set in the else handler) : Else then it will check if he is pressing the next key. And so on and so forth.. I hope that works..note: this method only works if it is set as a PARRALELL EVENT Share this post Link to post Share on other sites
Derek 3 Report post Posted October 19, 2009 I mean no offense to you Raiku, but the way you're explaining things makes them difficult to understand. I barely grasp the concept of what you're trying to say. I have created a system that I believe is much for efficient than that one there. My code leaves else situations out of the question, which will ultimately keep things more organized and less confusing in the end. It utilizes 1variable, 1switch, and 1common event also. @Figment: If you can't get the other system to work, please let me know. I have a DEMO ready for you, but Raiku was here 1st with his answer. http://www.rmxpunlimited.net/forums/index.php?app=downloads&showfile=229 Share this post Link to post Share on other sites
figment68 0 Report post Posted October 21, 2009 I mean no offense to you Raiku, but the way you're explaining things makes them difficult to understand. I barely grasp the concept of what you're trying to say. I have created a system that I believe is much for efficient than that one there. My code leaves else situations out of the question, which will ultimately keep things more organized and less confusing in the end. It utilizes 1variable, 1switch, and 1common event also. @Figment: If you can't get the other system to work, please let me know. I have a DEMO ready for you, but Raiku was here 1st with his answer. http://www.rmxpunlimited.net/forums/index.php?app=downloads&showfile=229 First of all let me apologize for taking so long to get back here, things have been hectic to say the least. Raiku, thank you for your excellent advice. The whole conditional branches with variables path is the direction that I was working in. I still could not quite get it to do exactly what I wanted so I checked back here and read what you posted, and indeed it did turn on a lightbulb or two as to what I was doing wrong. However my utmost thanks and eternal gratitude go out to Derek for the demo and the system. Works like a charm! Also it is event based, as I was hoping it to be, so I do not have worry about it interfering with my scripts. I will of course give full credz and much praise eternally. This system rocks! I also wanted to add that I am not the type to just copy paste and move on. I opened up the game and took the time to look and see exactly how it is set up so that I could see how I was doing it wrong. I was using the conditional branch with else statements to check each movement key and then else wait variable show animation etc., etc., and it would kinda' work but not anywhere as smoothly as this. Thank you for the help, for the demo, and for teaching me something. Share this post Link to post Share on other sites
figment68 0 Report post Posted October 21, 2009 [edit] Sorry, I seemed to have double posted. Share this post Link to post Share on other sites
Derek 3 Report post Posted October 21, 2009 I'm really happy that I could be helpful. I try my hardest to comment as many lines of code as I can, so that the event systems I distribute can be understood as easily as possible. Share this post Link to post Share on other sites
figment68 0 Report post Posted October 21, 2009 As soon as I opened it up and had a look at it I understood it easily. I immediately saw where I was going so wrong. I ran into a couple of problems with my Hero falling asleep during long conversations with NPCs, but it was easily fixed by turning off the trigger switch before a long conversation then turning it on again after wards. Hmmm, I suppose I could just modify the parallel process to check if the space bar is being pressed as well but I think that the way that I am doing it with turning the switch on or off works fine for my needs. Again I thank you and praise your awesomeness. Share this post Link to post Share on other sites
Derek 3 Report post Posted October 21, 2009 You're very welcome, and to your thoughts about the spacebar ... If it isn't broken, don't fix it =D. Good luck my man. Share this post Link to post Share on other sites