HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

few desnyc question

12-07-2007, 02:38 PM#1
zen87
Collapse JASS:
function omg takes real x, real y returns nothing
 local integer n = 0
    set bj_lastCreatedTextTag = CreateTextTag()
    loop
        if GetLocalPlayer()==Player(n) then
            call SetTextTagText(bj_lastCreatedTextTag,GetPlayerName(Player(n)),0)
        endif
        set n=n+1
        exitwhen n>11
    endloop
    call SetTextTagPos(bj_lastCreatedTextTag,x,y,0)
endfunction

will this cause desync? because someone said that changing the text in the texttag locally will not cause desync, well just to confirm.
12-07-2007, 03:13 PM#2
Malf
No, I don't think so since you can show a texttag locally to a player like so:
call SetTextTagVisibility(TextTag,GetLocalPlayer == YourPlayer)
12-07-2007, 03:19 PM#3
zen87
well i wish to do with the fuction above because i don't want to create an array of texttag and showing them one by one... so instead, changing the text of the texttag locally only requires one texttag and it shows all the things i need
12-07-2007, 03:44 PM#4
moyack
My suggestion to ensure that this won't desync is not using blizzard.j variables, instead, use a local one:

Collapse JASS:
function omg takes real x, real y returns nothing
 local integer n = 0
    local texttag t = CreateTextTag()
    loop
        if GetLocalPlayer()==Player(n) then
            call SetTextTagText(t,GetPlayerName(Player(n)),0)
            set n=n+1
            exitwhen n>11
        endif
    endloop
    call SetTextTagPos(t,x,y,0)
    set t = null
endfunction
12-07-2007, 03:47 PM#5
rain9441
It will desync, and not work properly, look at your loop...

If GetLocalPlayer() == Player(n) then set n = n+1 exitwhen n>11...

that will ONLY be true once, and for player 0 it will set n = n + 1 and loop forever because it'll never check the n>11 condition.

Best bet is to create the text tag and check if local player is player(n) then set visibility to true.
12-07-2007, 04:11 PM#6
zen87
Quote:
Originally Posted by rain9441
It will desync, and not work properly, look at your loop...

If GetLocalPlayer() == Player(n) then set n = n+1 exitwhen n>11...

that will ONLY be true once, and for player 0 it will set n = n + 1 and loop forever because it'll never check the n>11 condition.

Best bet is to create the text tag and check if local player is player(n) then set visibility to true.
ops, my bad, should put the n+1 and the exitwhen outside the if-then-endif statement...

there fixed, basically the function displace the players' name with ONE texttag...
12-07-2007, 10:38 PM#7
Toadcop
imho you can DO ANYTHING WITH TT'S localy cause texttag is a "local type"
yeah i think it's 100% so =) you can use globals for them etc.
(TT's are not saved by saving the game so don't operate with TT's after loading a saved game cause otherwise == crush (or maybe not =))
12-07-2007, 11:02 PM#8
Vexorian
I think it works, but I would do it this way:

Collapse JASS:
function omg takes real x, real y returns nothing
 local integer n = 0
 local string s
    set bj_lastCreatedTextTag = CreateTextTag()
    loop
        set s=GetPlayerName(Player(n))
        if GetLocalPlayer()==Player(n) then
            call SetTextTagText(bj_lastCreatedTextTag,s,0)
        endif
        set n=n+1
        exitwhen n>11
    endloop
    call SetTextTagPos(bj_lastCreatedTextTag,x,y,0)
endfunction

It is not likely at all that this function would be the first time you generate an string for player names, it is totally improbable that creating a local string object would cause issues, but I guess it is a risk that's not necessary so let's just avoid it...
12-08-2007, 03:20 AM#9
zen87
I see, thanks guys :)

--

Another question:
Then how about the multiboard? Can I change the string value in the multiboard locally? The example will be similiar with above, just dealing with multiboard now...
12-08-2007, 03:41 AM#10
Malf
If I'm not mistaken, you can also make multiboards locally for each player. But I think changing a string value may desync.
12-08-2007, 09:46 AM#11
Troll-Brain
the more safety way is to create the "object" and display it only for the local player, no ?
12-08-2007, 10:51 PM#12
Toadcop
Quote:
Then how about the multiboard? Can I change the string value in the multiboard locally? The example will be similiar with above, just dealing with multiboard now...
the feature is what it will desync if you will call a function localy. but if you would pass a local value to it then no ;)
i mean

if GetLocacPlayer()==Player(x) then
call MultiboardSetItemVal(i,i2,"my local val") // this will desync
endif



local string val="def val"
if GetLocacPlayer()==Player(x) then
set val="my local val"
endif
call MultiboardSetItemVal(i,i2,val) // this will work properly

see ;)
+ i think this also may work with some other interesting functions. maybe also you can set unit position localy =) (i havent checked it using local vals)

well it's the best solution use local values and not to call function localy ;)