Script call for Set Movement Route > Switch On

Discussion in 'Learning Javascript' started by JDevain, Oct 19, 2019.

Thread Status:
Not open for further replies.
  1. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    Hello,

    I'm trying to figure out the script call for Set Movement Route (for Event 001) > Switch On

    I found this in rpg_objects.js:

    Code:
    $gameSwitches.setValue(params[0], true);
    But I don't understand how to set it for a specific event (like Event 1), and I don't understand what to change "params" to. I assume I replace "0" with the number of the switch to turn on.
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    you're mixing up a lot of things here.

    1) switches are always independent of events - they have nothing to do with events, and that is why the script code you gave has no number for the events. You'll have to replace the entire params[0] with the ID of the switch you want to change.
    Code:
    $gameSwitches.setValue(10,true) 
    
    will turn ON the switch with the ID 10

    2) why are you trying to do this by script call instead of the event command control switch?
    3) what has this to do with set movement route?

    If you want help, I suggest you tell us what you want to do (ingame terms) instead of how you want to do it (programming terms), especially if you're that new and confused to mix up your programming terms.
     
    #2
  3. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    @Andar
    It's fairly complicated, but I'll go ahead and lay it out. I'm making a puzzle mini-game in which the player pushes different events around. Different events react differently to one another, depending on what kind of events they are. For example, if you push an apple next to a goat, the goat will eat the apple. If you push a torch next to a snake, the snake will move one space away from the torch. If you use a torch to push a snake next to a goat, the snake will bite and kill the goat. And so on.

    I needed a way to have events trigger other events just be being next to them. I tried using Galv's Puzzle Functions, but that didn't work for me because it only only triggers events that are above, below, left and right of the events, but not events in the 1,3,7,9 positions. Then I realized I could use Galv's Map Projectiles to achieve the effect I wanted. Simply have each event firing transparent projectiles in all 8 directions and have them go just 1 space. You can set it so that when a projectile from a map event hits another map event, it triggers a common event, and you can tailor it for each map event. Cool.

    This is where it gets a little complicated, because I'm also using Yanfly's Self Switches and Variables plugin. What I wanted to do was have the common event simply turn on a Self Switch for the event that got hit by the projectile, but that doesn't work with Galv's plugin for some reason. I noticed that if I used the Set Movement Route > Switch On in the common event, and specified that it was for Event 3 (for example), then it worked fine. Of course if I just used "Control Switches : #0010 Self Sw Whatever = on" then it doesn't work. I figured I could use

    Code:
    $gameVariables.setValue(99, Number(this._eventId));
    To get the event ID, and then use a script call for Set Movement Route, and specify the event ID there. After posting my original question, I realized that I could just use Yanfly's lunatic mode and use this in the common event:

    Code:
    this.setSelfSwitchValue(mapId, eventId, switchId, true)
    So I guess I was kind of going around the world just to get to next door. I've been using RMMV for a while, I just don't know javascript. Also, I ain't got a good brain.
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    This is the step where your logic went the wrong way, because you don't need that trigger.
    You need to backup a step instead.

    You already have an event that has been triggered - the one that moves the event into position.
    That event can also check what will be next to the moved event after it finishes moving (just a combination of coordinate mathematics and event command "get location info" and then add the changes after the move is complete.
     
    #4
  5. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    @Andar
    The map will have about a 120 events, which means, if I do it that way, 120 parallel processes all running at the same time. Seems a bit much.
     
    #5
  6. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    and where do you get that idea?
    Either your description is incomplete or your "step above" is also messed up, because you need ZERO parallel processes if you do it my way - all those events would be triggered by the player
     
    #6
  7. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    That would be great if there was a way to do it without running a parallel process, I just don't see how yet.

    OK, I'll explain in detail. Let's say I have two events on the map. One's an apple, the other is a goat. The player character walks up to the apple and collides with it. The apple event is triggered by player touch, and has Set Movement Route > Move Away from Player. Anyway, I push the apple event a few times until it is next to the goat event. I need for the goat event to somehow "detect" that the apple event is next to it, so that it can interact with the apple. This is what I meant when I said "For example, if you push an apple next to a goat, the goat will eat the apple."

    How would you do that without running a parallel process? I'm not ever actually touching the goat event, only the apple event. So how would it get triggered?
     
    #7
  8. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    wrong assumption here
    you don't need the goat event to detect that the apple is near, you need the apple event to detect that it will end up near the goat.

    when the player triggers the apple event, BEFORE the apple starts to move, you'll have to check where it will end up after the move. That is why you can't use a simple "move away", you'll check player facing with conditional branch and calculate the move in the opposing direction.

    then you'll check what other events will be near that target coordinate.
    if one of the events in those three (or eight if you allow for diagonal checks) positions is one that can interact with the apple event, then you determine what that result will be.
    then you move the apple and have all the required interactions displayed.
    Everything still under player touch trigger.
     
    #8
  9. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    That's the part I'm not clear on. How exactly do I do that? Remember, there are over 100 events on the page.

    Also, keep in mind that when explaining what I was doing in detail I said "If you push a torch next to a snake, the snake will move one space away from the torch", which means that it might move next to a goat and then have to interact with the goat. In other words, you'll sometimes be starting chain reactions.
     
    #9
  10. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    check the event command "get location info". you give it coordinates on the map by variable, and it loads info on that position into a third variable. You can select several different options, one is the event ID of an event on those coordinates (returns 0 if there is no event)

    OK, with chain reactions you'll need some parallel processes, but it would still be better to have a few parallel processs handle the entire game than using independent PPs for each event.
     
    #10
    JDevain likes this.
  11. JDevain

    JDevain Veteran Veteran

    Messages:
    81
    Likes Received:
    27
    Location:
    The Dirty South
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah, I see what you're saying. I overlooked Get Location Information. Thanks for your help!
     
    #11
  12. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,685
    Likes Received:
    4,162
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #12
Thread Status:
Not open for further replies.

Share This Page