Reset autoswitches?

Discussion in 'RPG Maker MV' started by Jogabba, Oct 29, 2016.

  1. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish
    Hi! I'm trying to make some sort of a "Choose your own adventure" game, which requires the player to go for more than only one playthrough.


    To do so, it would be necessary to reset all the autoswitches the player has activated during the previous playthrough. Is there any way to do so? Maybe there's another way to approach this problem? 
     
    #1
  2. Xenvex

    Xenvex Warper Member

    Messages:
    3
    Likes Received:
    0
    First Language:
    English
    Have you tried making an event at the end of the playthrough which turns off all switches in general? 
     
    #2
  3. Bex

    Bex Veteran Veteran

    Messages:
    1,153
    Likes Received:
    249
    First Language:
    German
    Primarily Uses:
    RMMV
    What is an auto Switch?


    I just know regular "Switches" and "Self Switches".


    Regular Switches:


    You use the Eventcommand Control switches and choose "Batch" that allows to turn of a range of switches at once.


    Self Switches:


    You use Eventcommand Script on Page3


    Here a simple script snippet made by a starter. Just execute it 1Time and all the self switches off all map events  on every map should be off.

    Code:
    
    for a in (1..999) 
    if $game_map.map_id != nil
    for b in (1..999)
    if $game_map.events[a] != nil
    $game_self_switches[[a, b, 'A']] = false
    $game_self_switches[[a, b, 'B']] = false
    $game_self_switches[[a, b, 'C']] = false
    $game_self_switches[[a, b, 'D']] = false
    end ; end
    end
    end
     
    Last edited by a moderator: Oct 29, 2016
    #3
  4. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,183
    Likes Received:
    254
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    do you mean like a new game plus? because else switches are remade at every time you start a new game...
     
    #4
  5. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish
    Sorry! With autoswitches I meant Self Switches.



    That would work fine, but you can't turn off self switches from other maps or events, right?

     
    #5
  6. Bex

    Bex Veteran Veteran

    Messages:
    1,153
    Likes Received:
    249
    First Language:
    German
    Primarily Uses:
    RMMV
    I made an error with the map id stuff, and i dont find the correct command i need.


    But i see that it doesnt crash if the map id isnt existing, so it works without that line, also decreases the lag spike for that 1 seccond.

    Code:
    for a in (1..999) 
    for b in (1..999)
    if $game_map.events[a] != nil
    $game_self_switches[[a, b, 'A']] = false
    $game_self_switches[[a, b, 'B']] = false
    $game_self_switches[[a, b, 'C']] = false
    $game_self_switches[[a, b, 'D']] = false
    end
    end
    end
     
    Last edited by a moderator: Oct 29, 2016
    #6
  7. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish




    Thanks for your help, I'm truly amazed with your kindness! 


    Both script snippets you've provided me do crash the game, though. SyntaxError: Unexpected Identifier. I'm not very experienced with script managing so maybe it's my fault. I just copied the script and pasted it in the line where I wanted to turn off all self switches.
     
    #7
  8. Bex

    Bex Veteran Veteran

    Messages:
    1,153
    Likes Received:
    249
    First Language:
    German
    Primarily Uses:
    RMMV
    Where exactly did you add it??? This is ment for use in Eventcommand on page 3 "Script".


    LOL its my fault, mine is for Ruby VX-Ace, i oversaw that this is for MV. Sorry me casa no Java Script  thingy :).


    Someone else will need to help.
     
    Last edited by a moderator: Nov 1, 2016
    #8
  9. Dad3353

    Dad3353 Veteran Veteran

    Messages:
    421
    Likes Received:
    108
    Location:
    France
    First Language:
    English
    @Jogabba...


    I got this to work, based on the above (which is not for MV, I think...)...


    ◆Script:for (var a = 1; a < 999; ++a)
    :      :{  
    :      :for (var b = 1; b < $gameMap.events().length+1; ++b)
    :      :{
    :      :$gameSelfSwitches.setValue([a, b, 'A'], false)
    :      :$gameSelfSwitches.setValue([a, b, 'B'], false)
    :      :$gameSelfSwitches.setValue([a, b, 'C'], false)
    :      :$gameSelfSwitches.setValue([a, b, 'D'], false)
    :      :}}


    It may not be perfect (suggestions for improvement welcome...), but I tried it out on a couple of Test Maps and it worked just fine. No guarantees, however.


    Hope this helps.
     
    #9
  10. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish
    I found an incredible simple solution. 


    $gameSelfSwitches.clear();


    This line seems to do the trick all by itself!


    Thank you guys for your help anyways, you're the best!
     
    #10
    Dad3353 likes this.

Share This Page