• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Locals set to globals but still local value...

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
so my problem is i am using Locals but then set to a global to use it with GUI but also becuz i need that global value to be recognized by all players.. but its still a local value within the global variable and doesnt show the same value to all players..

This is mostly dealing with this thread but the problem in the thread changed gears.. http://www.hiveworkshop.com/forums/triggers-scripts-269/multiboard-open-close-248764/
 
so my problem is i am using Locals but then set to a global to use it with GUI but also becuz i need that global value to be recognized by all players.. but its still a local value within the global variable and doesnt show the same value to all players..

This is mostly dealing with this thread but the problem in the thread changed gears.. http://www.hiveworkshop.com/forums/triggers-scripts-269/multiboard-open-close-248764/

Globals and locals refer to the scope of the variable. A global variable can be accessed anywhere, while a local variable can only be referenced/used within the function it is declared.

What you are looking for is actually known as syncing, which will make the value consistent between players. However, it is a little more complicated and will require JASS. See:
http://www.hiveworkshop.com/forums/...asy-way-sync-data-new-gethost-command-114475/

But there should be an easier way to do what you want to do. Have you considered using one multiboard per player?
 
Level 13
Joined
Mar 24, 2010
Messages
950
yes i am using a different MB for each player with array and displaying that MB to the correct player with local but the problem is that trigger i have posted in that link.

i use local code to make a decision if a MB is locally open for a triggering player then set that boolean to a global var
to use it in the gui trigger below
And more importantly what the Main problem is i use this in a different trigger as a condition
  • Conditions
    • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
So another trigger is only suppose to run if that boolean is true. Well here is my main desync issue..

Player 1 is the only correct one because lets say that value is false (and truly is false, or should be..)
Well player 2-8 see it as true when its really false.. so the stuff in that trigger runs when its not suppose to. and then desyncs the other players.

I dont think this issue is something that needs something as complicated as that game-cache method lol.

Im sure there is something simple im missing here..
Isn't there a way to set the true or false value from a local to a global that is recognized by all players like a normal gui global var?

Edit:
yea i just read that link and this issue has nothing to do with that, thats for syncing packets and game data with latency/delay of online gaming, my issue is an in-game problem with the code, that wont help this issue.
 
Hmmm... How are you reading it from the other players? that variable is a global in all ways that I see it...

if that is the trigger for all, then I can see why it won't work. Because that global is an array. If Player 1 opens it, it uses Variable[1 or maybe 0], if Player 2 opens it, it uses Variable[2] and so on... so you cannot expect player 2 to realize that player 1's board is open since your trigger only takes into account triggering player...
 
Level 13
Joined
Mar 24, 2010
Messages
950
Hmmm... How are you reading it from the other players? that variable is a global in all ways that I see it...

what do you mean?

  • Actions
    • Custom script: local boolean b = IsMultiboardMinimized(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())])
    • Trigger - Turn off (This trigger)
    • -------- it doesnt see this as open on other players comp becuz it doesnt see the local boolean --------
    • -------- so when player 1 open and closes it, it always displays open on player 2 comp --------
    • -------- which then doesnt change the global boolean messing up other triggers.. --------
    • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
    • Custom script: set b = not b
    • Custom script: endif
    • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], b)
    • Custom script: set udg_Temp_Bool = b
    • -------- When its Minimized its False --------
    • -------- If its true then its gonna Close, If its False its gonna Open --------
    • Set bool = Temp_Bool
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • bool Equal to False
      • Then - Actions
        • -------- Open --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
        • Camera - Lock camera target for (Triggering player) to Player_Hero_Array[(Player number of (Triggering player))], offset by (0.00, 0.00) using Default rotation
        • Game - Display to (All players) for 2.00 seconds the text: open
      • Else - Actions
        • -------- Close --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
        • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
        • Game - Display to (All players) for 2.00 seconds the text: closed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
      • Then - Actions
        • Game - Display to (All players) for 1.00 seconds the text: true = open
      • Else - Actions
        • Game - Display to (All players) for 1.00 seconds the text: false = closed
    • Wait 0.20 game-time seconds
    • Trigger - Turn on (This trigger)
you see the bottom game text notes? when i open the MB for player 1 it displays correctly, its says "true = open" and "false = closed" when it should.
But on player 2 it displays "true = open" everytime..

Except when i am using player 2's computer then the effect is the opposite. The messages are correct for player 2 but on player 1 the messages is always "true = open"
 
Level 13
Joined
Mar 24, 2010
Messages
950
And then on another trigger that has this as a condition
  • Conditions
    • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
It is false for player 1 (like it should be in the time of the test)
but that value is true for player 2. And i dont mean player 2 as in triggering player i mean Player 1's boolean is true in the eyes of Player 2 but false in the eyes of Player 1.

So the trigger does nothing for player 1 (which is correct)
but the trigger fires for Player 2 becuz player 2's games thinks its true and bam Desync.. -_-


Edit:
Those trigger parts are all thats needed, the actions on the trigger with that
  • Conditions
    • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
mean nothing and will just clutter, and the event of that big trigger also doesn't matter but its pressing the Esc key for players 1-8 ( it could be assumed it was that or typing a message, something that would fire from a triggering player event.)
 
Level 13
Joined
Mar 24, 2010
Messages
950
if that is the trigger for all, then I can see why it won't work. Because that global is an array. If Player 1 opens it, it uses Variable[1 or maybe 0], if Player 2 opens it, it uses Variable[2] and so on... so you cannot expect player 2 to realize that player 1's board is open since your trigger only takes into account triggering player...
--> and really, I cannot see any part of it where another player checks for the value of that variable for another player... The only player considered in the triggers you posted so far is only 1 player, which is Triggering Player...

No you dont understand what im saying (which isn't your fault) Its very hard to explain whats happening unless you have seen it.

What is happening is Player 1 pressed esp setting that MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True (TO TRUE)
Then Player 1 Pressed esc again setting
MenuOpen_Boolean[(Player number of (Triggering player))] Equal to False

When that other trigger runs that checks the condition
  • Conditions
    • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
Player 1 is making this trigger run..
So this trigger checks (triggering player) AKA Player 1 is running it
If MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
So for player 1 it doesnt run on that computer becuz that value is False

But in Player 2's computers eyes that value of
MenuOpen_Boolean[(Player number of (PLAYER 1))] Equal to True
is true.. (but it really is not suppose to be true becuz on player 1's comp it is False..

So its the same variable being checked but different values seen in that Same variable by 2 different users...

you see my prob now? lol
 
Level 13
Joined
Mar 24, 2010
Messages
950
so you want me to
  • Set Temp_Bool = True
before the local scripts? and then you think that will make it stay global after its value is changed from the local boolean?

Edit
u want me to give u the bb code to that trigger so u can change it to what u mean easier? lol
 
You would need to reverse the whole logic I think...

PS: W8, what are you trying to do again?

Also I seriously think that we need to see both triggers... and please include the whole trigger. You might think that it's not relevant, but it might. It's always better to give people the whole picture instead of showing them just a part
 
Level 13
Joined
Mar 24, 2010
Messages
950
lol but why.. what is your train of thought on this? how will changing how the trigger runs make it save that local boolean to a global var any better?

this:
http://www.hiveworkshop.com/forums/...als-but-still-local-value-248806/#post2492750

I need those global variables to actually be globals.. they arnt acting as such. is like that global variable has different values for different players.. its so annoying lol

My theory on it is becuz that 1st boolean is being done locally so other players have no clue about it that when its being set to that global Temo_Boolean, other players also have no clue so that Global boolean only has the value for that triggering player.. which makes no sense..
 
Level 13
Joined
Mar 24, 2010
Messages
950
lol fine here it is

  • Open Close Local 2
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
      • Player - Player 3 (Teal) skips a cinematic sequence
      • Player - Player 4 (Purple) skips a cinematic sequence
      • Player - Player 5 (Yellow) skips a cinematic sequence
      • Player - Player 6 (Orange) skips a cinematic sequence
      • Player - Player 7 (Green) skips a cinematic sequence
      • Player - Player 8 (Pink) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local boolean b = IsMultiboardMinimized(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())])
      • Trigger - Turn off (This trigger)
      • Set Temp_Bool = True
      • -------- it doesnt see this as open on other players comp becuz it doesnt see the local boolean --------
      • -------- so when player 1 open and closes it, it always displays open on player 2 comp --------
      • -------- which then doesnt change the global boolean messing up other triggers.. --------
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Custom script: set b = not b
      • Custom script: endif
      • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], b)
      • Custom script: set udg_Temp_Bool = b
      • -------- When its Minimized its False --------
      • -------- If its true then its gonna Close, If its False its gonna Open --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Temp_Bool Equal to False
        • Then - Actions
          • -------- Open --------
          • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
          • Camera - Lock camera target for (Triggering player) to Player_Hero_Array[(Player number of (Triggering player))], offset by (0.00, 0.00) using Default rotation
          • Game - Display to (All players) for 2.00 seconds the text: open
        • Else - Actions
          • -------- Close --------
          • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
          • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
          • Game - Display to (All players) for 2.00 seconds the text: closed
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to (All players) for 1.00 seconds the text: true = open
        • Else - Actions
          • Game - Display to (All players) for 1.00 seconds the text: false = closed
      • Wait 0.20 game-time seconds
      • Trigger - Turn on (This trigger)
  • Split
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Item carried by (Ordered unit) in slot 1) Equal to (Target item of issued order)
          • (Item carried by (Ordered unit) in slot 2) Equal to (Target item of issued order)
          • (Item carried by (Ordered unit) in slot 3) Equal to (Target item of issued order)
          • (Item carried by (Ordered unit) in slot 4) Equal to (Target item of issued order)
          • (Item carried by (Ordered unit) in slot 5) Equal to (Target item of issued order)
          • (Item carried by (Ordered unit) in slot 6) Equal to (Target item of issued order)
    • Actions
      • a super long trigger that shouldn't be running becuz of that MenuOpen_Boolean condition
ill read what u typed then edit this

Edit:
-->So to counter it, you would need to reverse your logic I think. Though I'm not sure if that will work or not...

-->PS: I don't think you really need to reverse the variable b... why not just do the Minimize inside the local player block instead of reversing b then minimizing outside of the block?

I kinda see what your saying but i kinda have a headache atm, can u maybe put your words into gui or custom script? i can see what your saying much easier that way lol
 
I think the only thing you need to do is that (using your original trigger not the edited one):

don't reverse b, just reverse the minimization itself for the local player + edit the next checks in case it changes the logic a bit... since the only thing that you need localized is the minimization anyways...

so you'd be doing it like

  • if GetLocalPlayer== blah then
    • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], (not b))
  • else
    • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], b)
  • end
PS: this will actually open it I think for all players when Player 1 closes it... you might wanna just do:

  • if GetLocalPlayer== blah then
    • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], (not b))
  • else
    • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], true)
  • end
or if you just wanna minimize it for everyone when it's opened by player 1

  • if GetLocalPlayer== blah then
    • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], (not b))
  • else
    • if b then
      • call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], true
    • end
  • end
and of course reverse the check for TempBool below, so that it now checks for TempBool is True

*I think*
 
Level 13
Joined
Mar 24, 2010
Messages
950
it was the same result when i tested it on LAN
even with the reverse logic.

The main issue here is this line of code.
  • Custom script: set udg_Temp_Bool = b
becuz when i then go to test this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Bool Equal to True
    • Then - Actions
      • -------- Open --------
      • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
      • Camera - Lock camera target for (Triggering player) to Player_Hero_Array[(Player number of (Triggering player))], offset by (0.00, 0.00) using Default rotation
      • Game - Display to (All players) for 2.00 seconds the text: open
    • Else - Actions
      • -------- Close --------
      • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
      • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
      • Game - Display to (All players) for 2.00 seconds the text: closed
it doesnt set those boolean arrays correctly globally for all players.

its setting Set MenuOpen_Boolean[(Player number of (Triggering player))] =
to true or false for Player 1 but for Player 2 etc its not setting it at all, whether thats true or false Player 2 always sees it as true somehow.
 
Level 13
Joined
Mar 24, 2010
Messages
950
i used your middle method on the above post and then reversed the check of Temp_Bool Equal to True
from false to true so it wasn't backwards

i didnt use "set b = not b" anymore

  • Actions
    • Custom script: local boolean b = IsMultiboardMinimized(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())])
    • Trigger - Turn off (This trigger)
    • -------- it doesnt see this as open on other players comp becuz it doesnt see the local boolean --------
    • -------- so when player 1 open and closes it, it always displays open on player 2 comp --------
    • -------- which then doesnt change the global boolean messing up other triggers.. --------
    • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
    • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], (not b))
    • Custom script: else
    • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], true)
    • Custom script: endif
    • Custom script: set udg_Temp_Bool = b
    • -------- When its Minimized its False --------
    • -------- If its true then its gonna Close, If its False its gonna Open --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Temp_Bool Equal to True
      • Then - Actions
        • -------- Open --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
        • Camera - Lock camera target for (Triggering player) to Player_Hero_Array[(Player number of (Triggering player))], offset by (0.00, 0.00) using Default rotation
        • Game - Display to (All players) for 2.00 seconds the text: open
      • Else - Actions
        • -------- Close --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
        • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
        • Game - Display to (All players) for 2.00 seconds the text: closed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
      • Then - Actions
        • Game - Display to (All players) for 1.00 seconds the text: true = open
      • Else - Actions
        • Game - Display to (All players) for 1.00 seconds the text: false = closed
    • Wait 0.20 game-time seconds
    • Trigger - Turn on (This trigger)

The main problem we are trying to solve here is this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Bool Equal to True
    • Then - Actions
      • -------- Open --------
      • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
    • Else - Actions
      • -------- Close --------
      • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
this MenuOpen_Boolean array value is not being set for all players to reginize only for Player 1 (or the triggering player whoever it may be)
 
Level 13
Joined
Mar 24, 2010
Messages
950
dude you crack me up lol
the only thing u are missing from that trigger is the events, why do u wanna see the whole trigger? this is all u are missing lol
  • Events
    • Player - Player 1 (Red) skips a cinematic sequence
    • Player - Player 2 (Blue) skips a cinematic sequence
    • Player - Player 3 (Teal) skips a cinematic sequence
    • Player - Player 4 (Purple) skips a cinematic sequence
    • Player - Player 5 (Yellow) skips a cinematic sequence
    • Player - Player 6 (Orange) skips a cinematic sequence
    • Player - Player 7 (Green) skips a cinematic sequence
    • Player - Player 8 (Pink) skips a cinematic sequence
Also check my edit above post ^
 
Level 13
Joined
Mar 24, 2010
Messages
950
ok so i used your 3rd method up above

  • Actions
    • Custom script: local boolean b = IsMultiboardMinimized(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())])
    • Trigger - Turn off (This trigger)
    • -------- --------
    • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
    • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], (not b))
    • Custom script: else
    • Custom script: if b then
    • Custom script: call MultiboardMinimize(udg_Menu_Inventory_12[GetConvertedPlayerId(GetTriggerPlayer())], true)
    • Custom script: endif
    • Custom script: endif
    • Custom script: set udg_Temp_Bool = b
    • -------- --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Temp_Bool Equal to True
      • Then - Actions
        • -------- Open --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = True
        • Camera - Lock camera target for (Triggering player) to Player_Hero_Array[(Player number of (Triggering player))], offset by (0.00, 0.00) using Default rotation
        • Game - Display to (All players) for 2.00 seconds the text: open
      • Else - Actions
        • -------- Close --------
        • Set MenuOpen_Boolean[(Player number of (Triggering player))] = False
        • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
        • Game - Display to (All players) for 2.00 seconds the text: closed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • MenuOpen_Boolean[(Player number of (Triggering player))] Equal to True
      • Then - Actions
        • Game - Display to (All players) for 1.00 seconds the text: true = open
      • Else - Actions
        • Game - Display to (All players) for 1.00 seconds the text: false = closed
    • Wait 0.20 game-time seconds
    • Trigger - Turn on (This trigger)
and the affect was reverse...
so now instead of player 2 desyncing when i run that unit trigger with my multiboad closed and it messing up now it messed up when the MB is open for player 1 which is more wrong. lol becuz when the MB is open for player 1 then its true and that trigger should run for everyone's computer.
 
Level 13
Joined
Mar 24, 2010
Messages
950
w8, it might be that multiboard check (I think it might always be returning true for other players since that multiboard is "always" closed for them)... have you tried using another method of checking?

yea that sounds about right, what other method of checking would i use?

but what i dont get is i then use that value returned as a global and then do the check and set that MenuOpen_Boolean[triggering player] global variable so then all players should see that global set right? regardless of whats done in the local code i would have assumed
 
Level 13
Joined
Mar 24, 2010
Messages
950
i might do that check locally but then in the lower code once i set that MenuOpen_Boolean[triggering player] global shouldnt that work? i would think..

But yea lets say what you are thinking is right, how do we get around that now
 
Level 13
Joined
Mar 24, 2010
Messages
950
Ok it is that local Minimize check, it works now with no desync.. but the problem is i need something to base that true or false off of..

becuz ppl might not always just use Esc for that MB affect they might be dumb and click that button on the MB to open/close it. So when that happens the Esc trigger has to be smart and self correct that.
 
On the times ESC is pressed and the initial setting. If the variable is false at init, then 1 press of ESC will "open" the board and set it to true, the 2nd press will "close" the board and set it to false and so on. It just won't get affected by when the player manually closes and opens the board using mouse click
 
Level 13
Joined
Mar 24, 2010
Messages
950
lol yea i edited that post before seeing you posted ^

but then it wont self correct and the affects will be backwards unless they fix it themselves. lol

Edit:
nvm the way i have it set now its already auto correcting now :)
I think all is well now, thanks a lot for thinking it out with me.
 
Status
Not open for further replies.
Top