I have a testing trigger for my map which should allow me to reveal entire map and cancell that functionality.
When i type "map" while the global condition for it is set to 0 it reveals the map and confirms it with text message "maphack on" and set g.c to 1 - and that works, it reveals the map and says "maphack on"
When i type "map" while the global condition for it is set to 1 it should remove the revealer and say "maphack off" - and it works with the message, but it doesnt cover the map with black mask and fog as it should...
p.s. offtopic
do i need to use global variables for such triggers like i did here (i wasnt sure if local variable isnt the problem so i have used global)? Are the local variables for triggers reseted each time the triggering event tuns the trigger?
p.s. offtopic do i need to use global variables for such triggers like i did here (i wasnt sure if local variable isnt the problem so i have used global)? Are the local variables for triggers reseted each time the triggering event tuns the trigger?
Correct; you should be using a Global variable for this function. To make a Global variable, do as SoulTaker916 posted:
on the left make a new variable. the type needs to be revealer
and make sure that after you create the variable, and give it a relevant name, like "Cheat Map Hack Revealer" or whatever you'll call it, definitely set the type of variable it is (there is a drop down list on the right window that is displayed, after you've selected the Global variable, to change what type it is) to Revealer.
Then, when the cheat is entered, you'll end up doing something like this:
(mind you this is pseudocode, and is meant for interpretation; you shouldn't copy-paste this directly into the Editor, and should instead read it and after understanding what it is meant to say then create the code)
Now, the reason you have to use a Global variable (one that is created on the master Left-List) as opposed to a Local variable (one that is created at the Top of the GUI Code editing window) is that when the Trigger is fully executed, and has finished its last line, the computer will destroy all of the local variables that were created in that function. If you created Cheat Map Hack Revealer in the Local scope, after the last line, "End If", the computer will have finished the code, and clear that Revealer variable out of memory, only to re-create an entirely new local variable the next time that the trigger is run.
What you're trying to do, I can tell, is use that Same Revealer every time the code is run, turning it on and off depending on what state the Cheat is currently in. Since you want that Trigger, every time it runs, to turn on or off a single Revealer, make the Revealer variable Global. This way, it can be created and stay in memory, without being deleted and cleared out, and instead be saved for the next time when it is time to shut it off or on.
Think about this:
If map==1, and it is now time to shut our revealer off, how are we going to tell the computer which revealer to shut off? We could potentially have 100's of revealers! If we tell it to turn off a Local Variable, Cheat Map Hack Revealer, remember this: the Cheat Map Hack Revealer variable is created new every time (staring out referencing Nothing as its set revealer) the Trigger is run - therefore, there is no possible way that Cheat Map Hack Revealer is referencing the revealer that we created when the cheat was turned on; the reference was deleted after the End If of when we turned it on, so there is no longer a way to control it!
BUT
If we used a Global Variable, there is a never-deleted Cheat Map Hack Revealer variable that won't be erased and recreated automatically. So, in the code, if we have the Global variable (Global being shared between all code, referencing one-unique revealer that never gets deleted) then when we say 'Disable Revealer (Cheat Map Hack Revealer), we are for-sure shutting off the one that we created last time the trigger made one.
Hope that didn't confuse you, and hopefully you don't have trouble reading my pseudocode;)
I have a testing trigger for my map which should allow me to reveal entire map and cancell that functionality.
When i type "map" while the global condition for it is set to 0 it reveals the map and confirms it with text message "maphack on" and set g.c to 1 - and that works, it reveals the map and says "maphack on"
When i type "map" while the global condition for it is set to 1 it should remove the revealer and say "maphack off" - and it works with the message, but it doesnt cover the map with black mask and fog as it should...
Whats wrong with it?
Thanks in advance.
p.s. offtopic do i need to use global variables for such triggers like i did here (i wasnt sure if local variable isnt the problem so i have used global)? Are the local variables for triggers reseted each time the triggering event tuns the trigger?
u need to set a variable for the revealer.
@SoulTaker916: Go
How should i do that? I played with it right now a bit but it didnt work.
on the left make a new variable. the type needs to be revealer
in your code under create revealer put set variable to last created revealer
then u will destroy that variable.
Correct; you should be using a Global variable for this function. To make a Global variable, do as SoulTaker916 posted:
and make sure that after you create the variable, and give it a relevant name, like "Cheat Map Hack Revealer" or whatever you'll call it, definitely set the type of variable it is (there is a drop down list on the right window that is displayed, after you've selected the Global variable, to change what type it is) to Revealer.
Then, when the cheat is entered, you'll end up doing something like this: (mind you this is pseudocode, and is meant for interpretation; you shouldn't copy-paste this directly into the Editor, and should instead read it and after understanding what it is meant to say then create the code)
Now, the reason you have to use a Global variable (one that is created on the master Left-List) as opposed to a Local variable (one that is created at the Top of the GUI Code editing window) is that when the Trigger is fully executed, and has finished its last line, the computer will destroy all of the local variables that were created in that function. If you created Cheat Map Hack Revealer in the Local scope, after the last line, "End If", the computer will have finished the code, and clear that Revealer variable out of memory, only to re-create an entirely new local variable the next time that the trigger is run.
What you're trying to do, I can tell, is use that Same Revealer every time the code is run, turning it on and off depending on what state the Cheat is currently in. Since you want that Trigger, every time it runs, to turn on or off a single Revealer, make the Revealer variable Global. This way, it can be created and stay in memory, without being deleted and cleared out, and instead be saved for the next time when it is time to shut it off or on.
Think about this:
If map==1, and it is now time to shut our revealer off, how are we going to tell the computer which revealer to shut off? We could potentially have 100's of revealers! If we tell it to turn off a Local Variable, Cheat Map Hack Revealer, remember this: the Cheat Map Hack Revealer variable is created new every time (staring out referencing Nothing as its set revealer) the Trigger is run - therefore, there is no possible way that Cheat Map Hack Revealer is referencing the revealer that we created when the cheat was turned on; the reference was deleted after the End If of when we turned it on, so there is no longer a way to control it!
BUT
If we used a Global Variable, there is a never-deleted Cheat Map Hack Revealer variable that won't be erased and recreated automatically. So, in the code, if we have the Global variable (Global being shared between all code, referencing one-unique revealer that never gets deleted) then when we say 'Disable Revealer (Cheat Map Hack Revealer), we are for-sure shutting off the one that we created last time the trigger made one.
Hope that didn't confuse you, and hopefully you don't have trouble reading my pseudocode ;)