Galv's Event Spawn Timers Help!

Discussion in 'Javascript/Plugin Support' started by deveras111, Jun 17, 2019.

  1. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm just trying to have a timer go off, but it wont happen ;_;

    As far as I know the syntax is correct! Any ideas?
    Screen Shot 2019-06-17 at 4.53.59 AM.png Screen Shot 2019-06-17 at 4.53.47 AM.png
     
    #1
  2. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @deveras111 I think you have the timer set up inside the movement route of event page 1 of event 3 based on what you have here. Is the timer supposed to throw switch 8 by any chance? If so...that's your problem. The page won't run until the timer's thrown...and the timer won't throw until the page runs. If that's the case, you need to throw switch 8 at least once before the timer can take over the spawns from there. It would help to be able to see the full script line of the movement command so we know what switch your timer is supposed to throw, as well as the other event pages, because this page may be getting superseded by a higher numbered page, which would also prevent it from running. Check that and let us know if you still have a problem. If you should still have a problem, please remember to at least include the full script line when you respond. Hope it helps! :smile:
     
    #2
  3. Bex

    Bex Veteran Veteran

    Messages:
    1,150
    Likes Received:
    247
    First Language:
    German
    Primarily Uses:
    RMMV
    The Code is executed Line after Line till it reaches the bottom of the Event, than it starts over again because its on parallel.

    Which Event is handling the Complaint Switch? because if that Switch is on, it could happen that your Variable counts to 4 and more but skips the branch for 3. And therfor Self Switch C will not be activated. Atleast thats what i spot on the Pictures. Hope this somehow helps.

    Edit:
    like mathmaster74 mentioned, new moveroutes overwrite old moveroutes, this also happens when changing eventpages, except for 1 circumstance which doesnt matter here right now.
     
    Last edited: Jun 17, 2019
    #3
  4. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Good point, @Bex :smile: The code on page 1 of Event 3 seems to be flawed in that Complaint1 will never equal 3 (unless it already does when the page starts with switch Complaint OFF...or starts at a value of 2 if switch Complaint is ON...both seeming highly unlikely since there's code to handle Complaint1 = 1). Follow me here: The switch Complaint is either ON or OFF when this page runs. If it's OFF (Case 1), then Complaint1 has to equal 1 or 3, or else nothing on this page runs except the first script line. If Complaint1 = 1 (Case 1a), then you add 1 to it, making it Complaint1 = 2...but since this case began with the notion that Complaint is OFF...and because it doesn't get turned back ON anywhere...Complaint1 will be stuck at 2...which again means nothing will run but the first script line. If Complaint1 = 3 (Case 1b), then the self switch changes the page...but it seems unlikely you would have that be the case...because otherwise...why the preceding code? Now consider case 2, where Complaint is ON. Here you add 1 to Complaint1, then turn Complaint OFF. Complaint1 at this point needs to equal 1 or 3 or else we're back to the same problem as Case 1. If Complaint1 =1 (Case 2a), then you add 1, making it Complaint1 = 2...but now we end up like Case 1a anyway because the condition Complaint1 = 3 won't run, the switch is OFF, and Complaint1 is not 1 anymore. If, on the first pass, Complaint1 was equal to 3 (Case 2b), then we get the same result as Case 1b...and the same question.
     
    #4
  5. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    It might help if i give some context to what I'm trying to do. as @Bex is probably aware of due to an earlier post, I am basically trying to make a barista simulator, where the player makes coffees and people come in to order them, and form a line. Should the player take to long to get through the line, it will take away one of three total lives until the player loses.

    Now I was interested in having two different mechanisms running per customer. 1. A way of setting up an event page so that the customer at the counter has a set time until he complains the player is taking too long, and then walks away which then reduces the players' life by one. There is also number 2. a way of setting of an event page so that as the customer waits in line, he complains (as a warning) then once he complains again he leaves and the player loses a life. I was quite interested in having both of these, but as there will be SEVERAL customers, and it seems as though Galv's event spawn plugin cannot have two timers work separate in one event, I have resigned to just figuring out the mechanism for the customers in line (as they will be the ones who will probably end up killing the player the most anyway)

    So what I have so far is this:

    Screen Shot 2019-06-17 at 1.58.31 PM.png Screen Shot 2019-06-17 at 1.59.12 PM.png Screen Shot 2019-06-17 at 1.59.25 PM.png Screen Shot 2019-06-17 at 1.59.33 PM.png Screen Shot 2019-06-17 at 1.59.39 PM.png Screen Shot 2019-06-17 at 1.59.48 PM.png

    The pictures go from lower pages to higher pages(1,2,3,4), sorry that I had the description in the way.

    Anyway, what I was planning to do was this:
    in the movement, it should activate the 5 second timer for the Complaint switch. In the first event page, it supposed to run the mechanism where given a certain amount of time waiting, Complaint will be turned on then add one value to Complaint1, then turn off Complaint switch. This should allow the first warning complaint in "If complaint1 = 1", as well as add a second value in order to lead to the customer leaving if he continues to wait (Which is what that "If complain1 = 3" and self switch c is for)

    Event page 2 is when the player will be informed of the type of coffee, and then run the mechanism of leaving when he gets his coffee (Event page 3). And Event page 4 is the "Walking away angry" mechanism.

    I am pretty new to RPG maker mv, so I probably have something pretty obvious wrong. I cant quite wrap my head around to how this timer stuff works. Every time I would put the this.setSpawn(x,x,x) in the movement route and it would show an error in the game. ;_;;_;;_;
     
    #5
  6. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @deveras111 Were you aware that the trigger for page 2 is set to Action Button for the trigger while the other pages are all set to Parallel? Just asking. There may have been a reason for it, or it may have been an oversight.

    EDIT: Okay. So, based on what you said you're trying to accomplish, @Andar is right...you need a plugin. Yanfly's Self Switches & Variables plugin will allow you to turn Complaint1 into a Self Variable for every event that spawns. Complaint1 would then handle the complaint count of the event. Now you can set up another Self Variable, maybe call it MaxComplaint, and set it to Random: Range: 1 to 2. Now you just compare Complaint1 to MaxComplaint after every new complaint comes in (Every time Complaint1 += 1 in the event), and if that event has reached its own MaxComplaint, set it to walk away. Otherwise, keep it waiting and preparing to either complain again or be served.

    EDIT 2: Got my threads crossed. :oops: Andar said a plugin was required in another thread...still...this is how I think you want to handle things here for simplicity's sake.
     
    Last edited: Jun 18, 2019
    #6
  7. Bex

    Bex Veteran Veteran

    Messages:
    1,150
    Likes Received:
    247
    First Language:
    German
    Primarily Uses:
    RMMV
    Edit:
    I like your Idea, would also like that you get it to work. Will create a Testroom and see what i can do.
    Here the Link to Self Variable Plugin:
    http://yanfly.moe/2016/08/06/yep-113-self-switches-variables-rpg-maker-mv/
    If you name a Variable include: Self Var in the Name. For example: Self Var TimarA.
    This is what i got so far:
    I made 1 Parallel Event which contains a Script snippet, that can check and control the Timers for 1 to 999 Customer Slots. I used Yanflys Self Variables Plugin, and made Variable1 into a Self Variable.
    If you want to Set a Timer for a customer Event, you need to use this Scriptline 1 Time when customer timer should start.
    Code:
    this.setSelfVariableValue($gameMap.mapId(), 3, 1, 180)
    Code:
    this.setSelfVariableValue($gameMap.mapId(), A, B, C)
    A = Event ID, B = The Self Variable of that Event, in our case Variable1
    C = The Timer Start Value itself, 60 = 1Second but if you put a wait 60 frames eventcommand after the code shown further below, 1 becomes 1 second.
    Here the Scriptsnippet of our paralell control Event, use this in Eventcommand Script which you find on 3rd Page of Eventcommands.
    Timer of Event Ids 1 to 50 are checked and controlled.
    Code:
    for (var a = 1; a <= 50; a++) {
      if (!!$gameMap.event(a)) {   // check that event exists
       if (this.getSelfVariableValue($gameMap.mapId(), a, 1) > 0) {
         this.setSelfVariableValue($gameMap.mapId(), a, 1, this.getSelfVariableValue($gameMap.mapId(), a, 1) - 1)
           if (this.getSelfVariableValue($gameMap.mapId(), a, 1) == 120) {
    $gameSelfSwitches.setValue([$gameMap._mapId, a, 'B'], true) }
      if (this.getSelfVariableValue($gameMap.mapId(), a, 1) == 0) {
    $gameSelfSwitches.setValue([$gameMap._mapId, a, 'C'], true)
     } } } } 
    If Timer reaches 120, Self Switch B of that Event is turned On, if it reaches 0 self switch C is turned On. 1 to 999 Customer Slots can be handled with this. You maybe just need 10 to 20 customer slots max. If you like this Idea, it could be Edited to your needs.

    Ignore the spoiler it was a stupid idea to use moveroute for that. I canceled that approach.
    While reading the Forums i maybe came up with an alternative for your Timer and the customer Event.

    Autonomous Movement on the customers Eventpage can be used for moving up and doing a if condition and count a variable down.
    I assume this is a terrible way of counting, but it seems to work so far. But it Limits the Customer to 1 Movecommand
    and a Codeblock which repeat or skip if cannot move.

    At Gameteststart set Variable1 to random 300 to 600, that should be 5 to 10 or more seconds inside the moveroute with frequency on highest.

    This comes into the autonomous moveroute:
    Code:
    if ($gameVariables.value(1) === 0) {$gameSelfSwitches.setValue([$gameMap._mapId, 1, 'C'], true)} else {$gameVariables.setValue(1, $gameVariables.value(1) - 1);} 
    With this simple Build, the NPC can just Move up in waiting line while he is counting his own Timer and that without parallel eventpage, we got it on action button so player can speak to customers. (Dont forget to mark skip if cannot move and repeat in the Moveroute).
    This happens in Game:
    Customer moves Up 1 Step if possible or skips, than
    If Timer is equal 0 ? Activate Self Switch C else Sub 1 From Timer Variable.
    Self Switch C is Condition for the Next Parallel Eventpage where for example the Customer Complains or gives a Complaint Warning.

    The Timer doesnt run when Customer is spoken to.
    The Timer doesnt run while the Customer executes the visible Move to the next Maptile.
    Therfor this can be influenced by frequency and speed setting of Eventpage.
    If the Customer isnt moving or cant move, the Timer will run on maximum speed. 60 = 1 Second

    Maybe this helps somehow if an alternative is needed.

    Edit: With more code the moveroute could be adjusted so the event can walk more than just up and up again.
     
    Last edited: Jun 19, 2019
    #7
  8. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes I was aware, it's so that the player can go back to the customer and reference his order should he forget a detail.

    That idea is very interesting, I will look into the plugin, thanks!
     
    #8
  9. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, so I've downloaded the plugin. You said I should use this scriptline to set a timer for a customer event, so would this script add 1 value to Variable1 every 3 seconds? How would this work in relation to the multiple complaints I want the customer event to make before reducing a life?


    I see how I'd be able to incorporate the complains in this, for example maybe have a show text command on a second event page under the condition for self switch B. This seems like exactly what I need!:D However, I have 0 experience with scripting! So I am unsure how this would work exactly, would I have to put these scriptlines in every single customer or would I just have a parallel event on the side?

    This seems like a great idea, how could it be edited more for the design of this game?


    The plan is to have the customer wait to give there order. However, If they are waiting too long, they will complain and eventually leave without reaching the counter. Once they are at the counter, the original plan was to have a separate mechanism begin where they would give their order, and then if it took too long complain and eventually leave.

    This is going to be one customer at the counter at a time, however, later in the game, another line will open where more customers will line up. Thus the player will have to balance between these two lines.

    Ultimately my plan is to have a "Rush hour" mode where customers will have even shorter "complaint" times and the player will have to be quicker than usual and get through as many customers as he can.
     
    Last edited: Jun 20, 2019
    #9
  10. Bex

    Bex Veteran Veteran

    Messages:
    1,150
    Likes Received:
    247
    First Language:
    German
    Primarily Uses:
    RMMV
    - This is used as Parallel Event on the Side. Not in every Customer.
    - Timer are not counting up, they are counting down, if they are set to a wait time.
    - Activating self switch B and C for other Eventpages was a mistake of mine, because it interrupts the moveroute of that eventpage.
    But if the complaint is just a Show Balloon Icon, than the code itself could be edited to do it automaticaly.
    - The Customers long moveroute while being in waiting line, this keeps us from changing eventpages,because we would kill the moveroute. We need the triger be on action button , because we want to talk to that NPC. That means we need to exclude everything else into a controlling Event. Timers, Complaints and there Textboxes and so on...
    At first i also thought we could do it with multiple eventpages and stuff, that just lead to all this confusion and Bugs and Errors after every second corner. Sorry.

    Sorry for the confusing start, iam not a Scripter and just a casual User.

    Edit: To make a Event Self Variable out of Variable 1 you need to include this into its variable name: Self Var
     
    Last edited: Jun 20, 2019
    #10
  11. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes changing event pages would be a problem. Perhaps theres an easier solution in using wait times? I could have it so that the event page with the move routes contain wait times acting as timers, and at the end of every wait time there could be a complaint. This is dependent, however, on whether at the end of the move route once the customer gets to the counter, if I put a "self switch A on" command does it immediatly switch or will it finish the event page first before switching. I will try this and get back to you.
     
    #11
  12. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    By George, I think I've got it! :kaopride:

    By simply setting two different Wait Event commands, and a Show text at the end of each of them, I basically have simulated the customers getting impatient and leaving, I just have to get the wait times correct! Four days of trying to jerry-rig a more complicated solution and the wait times figured it out.

    And as for Galv's spawner timers? Didn't have to use them at all! But I suppose that's just how it goes.

    Thanks to everyone for you help, especially @Bex for being so helpful in figuring out what works
     
    #12
  13. Bex

    Bex Veteran Veteran

    Messages:
    1,150
    Likes Received:
    247
    First Language:
    German
    Primarily Uses:
    RMMV
    I hope the Timer helped in the End, if it doesnt help or if something is missing or if you dont understand something , let us know.
     
    #13
    deveras111 likes this.
  14. deveras111

    deveras111 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Will do!
     
    #14

Share This Page