Hello! It's possible to work together, but I want us both to understand a bit more before doing anything.
Thanks for the reply! Glad you're looking into this.
You may not already know, so I'll explain a bit about this mod's principles.
- Entering a Sandbox must always swap to the God Controller
Entering a sandbox happens on your end. I just need to know that you will switch to the god controller BEFORE you actually do that, so that I can update my data and the player's GUI.
- Exiting a Sandbox should always try to return to whatever "state" the player was originally in (quite complicated, exceptions apply)
My mod only deals with character, editor, and god controller. Before leaving character mode for editor or god mode, I back up the player's character, so I can reattach it when the player returns to character mode. This should work even if the player decides to return to character mode by selecting a different character (first step is reattaching the old character, second step is replacing it with the new one).
- The Sandbox's inventory must appear real and persistent
Your job! I only care about the inventories of characters; these are distinct from the editor/god mode inventories.
- Potentially implied by the first bullet: while in a Sandbox, the player should always feel at least like that God Controller does
Sorry, I really don't understand what you mean here.
That second bullet is the hardest part of all of this. There are situations where we basically cannot return to that original state, and in that case our last-resort is to prevent entering the Sandbox if we cannot gracefully return out of it. For example, a player on a normal character who has already changed to another controller type for some other reason - we may only know this state to revert back to, but that may lose the original/home state and "disembody" the player.
Did you try out miniMAXIme yet? If not, download it together with a couple of character mods (see the optional dependencies). Make sure you have a character, don an armor and put some stuff into your inventory. Switch to god mode, then to editor mode, then back to a character. Check your inventory -- it should have the same contents as it had before you turned on god mode, even if you have switched to a different character.
By the way: My mod supports the Lua API global Variable Viewer (gvv), so if you're using that, you can follow what's going on in my global table. It also has a startup setting for activating detailed logging (off by default), showing what functions get called with what arguments etc.
I think the implications of the above are:
- Don't allow character switching within Sandboxes
- Do allow God/Editor Controller swapping within the Sandboxes
My GUI will always show the character buttons, only the buttons for god/editor mode are optional (locked behind a map-setting, and only usable by admins, which includes the player in single-player mode). Hiding the character buttons while keeping those for god/editor mode seems like more trouble than it's worth, given the alternatives:
- Space Exploration has a kind of remote view (called "Satellite Navigation Something-or-other") which actually is god mode. If a player has this mode enabled and uses my GUI to switch to character mode, I call a remote function of SE to stop its remote view. If you had such a function, I could request a stop of sandbox mode as well.
- Alternatively, I could hide the GUI of players who have entered sandbox mode until they leave it again. This requires that you announce the mode change -- either by raising a custom event, or by calling a remote function provided by my mod.
I can think of further points than that,
Sure, go on! :-)
but I want to pause and see what you think an integration means.
Basically, my mod can only work correctly if a player's controller type is in sync with what the mod thinks this player's controller type is. That's no problem where editor mode is concerned (we can listen to defines.events.on_player_toggled_map_editor
and defines.events.on_pre_player_toggled_map_editor
), but there are no vanilla events for god/character mode or for when a player's character is exchanged.
Suppose a player had a character and used my GUI to change to god mode, then some other mod was stopping god mode by creating a new character and assigning it to the player. If the other mod doesn't announce the mode switch, I can't remove the player's old character, and the surface will eventually be spammed with unused characters.
If there's anything that you need done on my end, just say so and I'll try to provide it. :-)