Common Event on parallel process not working.

Discussion in 'RGSSx Script Support' started by Kes, Jan 13, 2014.

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

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    Objective

    The script I am referring to in this is Shaz's mouse script here: http://forums.rpgmakerweb.com/index.php?/topic/17829-amaranths-super-simple-mouse-system-for-ace/ but that is not the issue.

    I want to give the player the choice of enabling or disabling the mouse.  This can be done by a script call.  However, the value generated by the script call is NOT saved anywhere. If you want your game to remember that the mouse is enabled or disabled, you will need to set something up to call one of the commands whenever the game is launched, or a new game started or a saved game is loaded, depending on how global you want the mouse setting to be. So my objective is to find a way of doing just that.

    The only way I could think of doing that was to have a common event on parallel process that would (I thought) run automatically whenever the game opened.  It would check to see if a particular switch was on or off and do the script call as required.  I had hoped that 'erase event' would operate, but it seems that it doesn't.  I know this because I put in a piece of text at every stage to find out what was or wasn't running, and even with erase event it still kept on looping.  

    There may be several reasons why it's not working, but here is the screen shot of how it looks at the moment.

    [​IMG]

    I couldn't find a way of having this without a condition switch at the top.  The problem with that is that if the switch is OFF then the event won't run.  If the event doesn't run then the script call for 'false' is not made so if the player has chosen to disable the mouse that will be ignored the next time the game is started and the script default (true) will operate.  I don't want the player to have to chose every time they open up.

    I think I have set this up entirely wrong, but can't see how it should have been done.  You can see from the screen shot what the 2 script calls are.  Can this event be fixed, or should I be doing this a totally different way?

    Thanks.
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,672
    Likes Received:
    6,594
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    the switch to check for the mouse ON/OFF needs to be a different switch than the switch for activating the event.


    Yes, this is a terrible way to do that - I would suggest using an option script to change the switch, not a parallel process...


    where does the player set the switch 200? this isn't part of this process.
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


    There are better ways of doing it than that.


    There are some scripts around that let you save 'global' data. Whenever the mouse is enabled or disabled (you can change the mouse script and add this into the def enabled= method) have it save the value to the global data as well. Then when you launch your game and the global data is loaded, add a line into the script to set the $mouse.enabled to that value from global data.


    Or if you want it on a game-by-game basis (so one save file would have the mouse turned off, and another have it turned on), change the mouse def.enabled= method to put the value into a game switch. Then when the game is loaded, have it call $mouse.enabled=($game_switches[id]).


    Try it out, and if you can't get it working, post back and I'll give you a little script mod that will use the second method, since I don't know if you're using a preferences file or a global data script.
     
    #3
  4. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    @Shaz

    I searched the master script list using both 'global' and 'data' and didn't come up with anything.  What should I have been searching for?

    I don't understand your suggestion in your second paragraph.  I assume it's got something to do with a global data script.  The objective you mention there of allowing the player to have save files with different mouse choices is what I would like; I want to give them the freedom to change their choice as they go along if they want to.

    I'm not using a preferences file or a global data script.

    I am in my usual state when it comes to scripts - lost and confused.
     
    #4
  5. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,071
    Location:
    Toronto
    First Language:
    English
    Do those script calls actually enable/disable the mouse?
     
    Last edited by a moderator: Jan 13, 2014
    #5
  6. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    Yes.  I have tested them out using events which I click on using a 'show choice'.  The switch goes on or off as as the case may be, the mouse appears or disappears as appropriate.  So I know the script calls work, which is why I also know that my attempt to get that data carried over when the game is reloaded didn't work, as I was back with the default setup.

    As far as I can see, to achieve my objective requires me to do 3 things.

    Ensure that the script calls work (done)

    Find a way for the data to be saved and loaded each time (this topic)

    Incorporate the choice into Yanfly's Options in the main menu.

    EDIT

    The first phase is because I want the player to make an initial choice at the very beginning of the game at the same time as they are choosing difficulty level and visible or invisible enemies, hence the 'show choice' route.
     
    Last edited by a moderator: Jan 13, 2014
    #6
  7. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Hime, if you look at it (I'm about to go off to work and won't be back for 8+ hours), the calls are:


    $mouse.enabled = true/false


    I think allocating a game switch to hold this value, then setting that game switch in the mouse sprite's enabled= method will save it. Then when a game is loaded, after the load, do a call to $mouse.enabled = $game_switches[id].


    That should be all that's needed, with the additional security check of only setting the switch if $game_switches is not nil.


    And maybe a call to set it to true when a new game is started.


    ksjp17, how do you let the player toggle the mouse during the game?
     
    Last edited by a moderator: Jan 13, 2014
    #7
  8. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    My plan is to incorporate this as an extra line in Yanfly's Options System in the main menu.  There is a facility there to add another couple of choices on top of autodash, instant text etc.
     
    #8
  9. Andar

    Andar Veteran Veteran

    Messages:
    28,672
    Likes Received:
    6,594
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Instead of going around with the script calls, enter the function calls directly in the option script.
    I don't know the two scripts, but if the option script sets the value, you are already on the script level - no need to go back to the event level and back to script calls by parallel processes...


    If you need a persistent data script for other functions, search in the ReStaff archives - in one of them (don't know which) Fomar included a script to store data for later games that works with the ini-file, no need for anything else.


    Unfortunately that script is not in any forum or on the master-script-list, you'll have to search through the ReStaff-Downloads to find it.
     
    #9
  10. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    So, do you need help with that?
     
    #10
  11. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The problm is not how to call the script to toggle the setting (unless he does need assistance with the Options System script).  The problem is making it REMEMBER that setting, so next time you play, it doesn't revert back to the default.

    The preference is to have the setting saved per save file so different save files can have different settings.  So the .enabled= method needs to update a switch each time it's called.  Then the load_saved_game and setup_new_game methods (I don't know if they're the correct names) need an extra line added to call $mouse.enabled= and enable or disable it according to the variable (or enable it by default with a new game).

    I know exactly what needs to be changed and where.  I just can't do it right now because I'm not at my computer and don't have RM open in front of me.  I'll take care of it when I get home this afternoon.
     
    #11
  12. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    Switches are saved right? so that means Yanfly's script automatically reverts it back to the default once you replay?
     
    #12
  13. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    There is nothing set up yet to call the mouse enable/disable method when a saved game is loaded, or to set the switch when the mouse is enabled or disabled.  That's what he's asking for.
     
    #13
  14. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,969
    Location:
    Philippines
    First Language:
    Tagalog
    I see... anyway, I saw his other thread and it seems like the switch thing works but only when he does it via events; using yanfly's scrip doesn't seem to work...
     
    Last edited by a moderator: Jan 13, 2014
    #14
  15. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    I think that until this problem is sorted, Yanfly's script can't work.  Or if there is a separate issue there, it will be easier to deal with once I am sure that the data is being remembered.
     
    #15
  16. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, try this ... I have not tested it (sorry), so post back if you get an error. This will JUST save the mouse enabled/disabled status in your save file, and set it correctly when you load a save file or start a new game. It's got nothing to do with toggling it or with any options menus.

    In a new slot below the mouse script.

    Allocate a switch (and name it!) to be used for this, then change the ENABLED_SWITCH to have that switch id. Make it like 8, not like 008 - no leading zeros.

    module SHAZ module MouseSwitch ENABLED_SWITCH = 1 endendclass Sprite_Mouse < Sprite def enabled=(value) @enabled = value $game_switches[SHAZ::MouseSwitch::ENABLED_SWITCH] = value self.visible = value endendmodule DataManager class << self alias shaz_mouse_switch_load_normal_database load_normal_database alias shaz_mouse_switch_setup_new_game setup_new_game end def load_normal_database shaz_mouse_switch_load_normal_database $mouse.enabled = $game_switches[SHAZ::MouseSwitch::ENABLED_SWITCH] if $mouse && $game_switches end def setup_new_game shaz_mouse_switch_setup_new_game $mouse.enabled = true if $mouse endendNow, when you get to putting it into your options menu, you must still use the $mouse.enabled= method call. Don't just link the option to the switch, because that'll just change what happens NEXT time you load the saved game, but it won't actually toggle it there and then.
     
    #16
  17. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    Maybe I did it incorrectly, but this doesn't seem to work.

    I chose switch #299 and put that into the script at line 3.

    I set up an event - show choice enable/disable.

    for enable 

    Switch 299 ON

    script call $mouse.enabled = true

    For disable

    Switch 299 OFF

    script call $mouse.enabled = false

    This works in-game.  Save with the setting OFF, so disabled.

    Close down the game, re-open.

    Switch still OFF but mouse is back to default, so enabled.

    Did I do it correctly?
     
    #17
  18. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    No, get rid of the event - especially if you've still got it running on parallel processing.

    You don't need to do ANYTHING with the switch (and in fact you SHOULDN'T change that switch - the whole point is the mouse script changes it and checks its value) - you JUST need to do the script call.

    If your event is just for testing, do it something like this:

    Show Text: Do you want the mouse on or off?Show Choices: ON, OFFWhen ON Script: $mouse.enabled = trueWhen OFF Script: $mouse.enabled = falseBranch EndThen use that event to test it. If you start a new game and set it to OFF, then save the game, go back to the menu, start a new game, set it to ON, save it, you should be able to alternate loading the save files, and the mouse should switch on and off according to its status when that game was saved.
     
    Last edited by a moderator: Jan 13, 2014
    #18
  19. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,047
    Likes Received:
    10,697
    First Language:
    English
    Primarily Uses:
    RMVXA
    I amended the test event as you said. It will save the disabled setting if I return to the title screen and reload but if I close down completely when I reopen it's back to default enabled.
     
    #19
  20. Shaz

    Shaz Veteran Veteran

    Messages:
    37,911
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    It's enabled on a new game by default.


    Are you talking about when you're in the menu, or have you loaded a saved game where you HAD disabled the mouse, and it's enabled again?


    When you launch your game, there IS no saved game, so it's enabled by default. It changes when you start a new game or when you load a saved game, not when you start the game and go to the title screen. Because you said you wanted it to be linked with the save file, not global (and title screen is global, not linked to a save file)
     
    #20
Thread Status:
Not open for further replies.

Share This Page