Hello!
I am trying to show a window that a player can turn on/off as they please. I am using the switch "Show Window" obviously set to either ON or OFF. I use the Quick Event Creation > Switch and select the appropriate icon and when I run a test it works perfectly turning the window on and off. However... this isn't meant to be a physical switch in the map's physical location and interacted with the player's character. I think of it more as a player's HUD.
But clicking on the event obviously moves the player's character to that switch every time the player tries to turn the window on and off. Does anyone know a way that it can maintain the functionality without causing the character to move? I have tried various methods of autorun to not move the character but then switch is on a continuous loop and the switch keeps changing states. I also tried and Set Movement Route >Player empty with no movements on both event pages and the character still moves to it.
I am open to any suggestions using the method I've tried or another method.
That script disables player movement controls. It sounds like you have some cutscene sequence that's scripting "player" movement.
You also said you're using a loop so basically you're just automatically turning movment controls off and on every x frames.
I looked more closely, and you're actually correct. The code is formatted in a confusing way that makes it look like the assignment to moveByInput is inside the if == undefined, but it's actually not. Normally, you would at least indent the second line of code to make that clear, or even add braces around it.
In any case, the code doesn't really apply to the original poster's problem as I understand it…
Alright..so far I tried both codes but the character still moves to the event when clicking on it. I have used both the same way that I put in the code section of my second post. Since I started with a Quick Event > switch it automatically sets up two pages where the second has the condition of the switch being on and the first page has no conditions which is off since switch=off is not a usable a usable condition by default.
So I tried both codes putting the disable movement right at the top of each of the event's pages and then put the re-enable codes just above the switch assignment to either on or off. I believed that this would disable movement when the mouse i clicked on the event as the trigger for both pages is Action Button and then would re-enable movement so that the player can move their character again after they've clicked the button/switch. But I've tried that with both codes and the character still moves so I am wondering if I do not have it set up right or am using them incorrectly. The code in my previous post shows what I am doing on just one page but I am doing the same on both and the character moves to the event/button when using the switch/button for both on and off.
So far in this game I do not move character with commands at all. And on the map where I am trying to get this to work I am not moving any NPCs or the character. So there should be nothing else causing player character movement that would override a script like these. I am using only a few plugins and none of them affect or are affected by a player moving their character.
Not a loop problem as I removed the looping before I posted this. I was trying to see if using Autorun as the trigger would inhibit the character moving...which it did..but then the event just kept running and the event button just kept changing states and the window that the switch Show_Window contols kept appearing and then hiding appropriately. So it did accomplish the task of the player's character not moving to the switch when clicking it but the autorun caused a loop. So I removed that before my original post starting this thread. I only mentioned that I had tried that in case anyone were to ask me what I tried doing.
I have tried both of the JS that were offered but neither stopped the movement to the button when clicked. But I am not sure that I am putting the code where it should be. It made the most sense to put it where I did but that isn't working and if both codes work then I have to assume that I am putting them in the incorrect place. I am using Advanced (on the 3rd tab) - > Script and pasting the script. With the disable at the very top of each event page and the re-enable movement script at the bottom.
So, it sounds like the issue is that you have a UI element that you need to turn on when it's clicked, but you don't want the player to move to it when it's clicked (which is what happens when you make the element an event on the map).
Would the ButtonPicture.js plugin (one of the default plugins) solve the issue? It triggers a common event when a picture is clicked. While I haven't had to use it for a project yet, it would be my first try for any sort of clickable UI.
I appreciate your response and I did run into ButtonPicture.js once I paid attention to the plugins that were in there by default. I did work with it very briefly but I ran into that while I was working on another feature in the game so I did not give it serious look into yet. If I figure out how to properly employ it then it should do what I need. I was only going with a physical graphical switch as I felt that it would also work for the UI graphic element. I am going to try this plugin once I return my attention to that feature.