• 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.

[JASS] JASS Simplify (NEWB Question)

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
ok im a really newb at JASS (was a bit lazy to learn it, until i got realized of its powers) and i need to know if there is a more efficient way the next script can be done: (i think there is, by using a loop or more like a function. I think its too long and can be shorter by using another method)

  • WindowShow
    • Events
      • Time - Elapsed game time is 1.50 seconds
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[1],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(1) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[2],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(2) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[3],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(3) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[4],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(4) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[5],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(5) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[6],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(6) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[7],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(7) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[8],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(8) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[9],true)
      • Custom script: endif
      • Custom script: if GetLocalPlayer() == Player(9) then
      • Custom script: call MultiboardDisplay(udg_Multiboard[10],true)
      • Custom script: endif

thanks in advance :)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
JASS:
local integer i = 0
local integer players = someNumber // this is how much players play currently
loop
     exitwhen i = players
     if GetLocalPlayer() == Player(i) then
           call MultiboardDisplay(udg_Multiboard[i],true)
     endif
     set i = i + 1
endloop


And why don't you type in jass instead of custom scripts ? :p
 
Level 6
Joined
Jun 30, 2006
Messages
230
GhostWolf, notice that the multiboard index is one higher than the player index...
The entire trigger should look something like this:
JASS:
function Trig_WindowShow_Actions takes nothing returns nothing
    local integer i=0
    loop
        exitwhen i>9
        if GetLocalPlayer() == Player(i)
            call MultiboardDisplay(udg_Multiboard[i+1],true)
        endif
        set i = i +1
    endloop
endfunction

//===========================================================================
function InitTrig_WindowShow takes nothing returns nothing
    set gg_trg_WindowShow = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_WindowShow, 1.50 )
    call TriggerAddAction( gg_trg_WindowShow, function Trig_WindowShow_Actions )
endfunction
 
Level 6
Joined
Jun 30, 2006
Messages
230
@Poot
I just copied GhostWolf's code and changed some numbers to be what they were supposed to and added the InitTrig. I remember when I was starting out, it bugged me that when people helped me, they automatically assumed that I knew which events/conditions to use. Also, my page was cached locally and I didn't see EF's post, or I would have taken his code and added an InitTrig... :)
 
Level 5
Joined
Sep 13, 2007
Messages
33
> Gets the player behind the keyboard of the machine it is running on.

In other words...

Each function called runs on each player's computer seperatly. In order to refer to the player that the function his executed at is computer use GetLocalPlayer().
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
IQ's got nuthin to do with it

I just don't know JASS ><

I don't really have such good knowledge of multiplayer online programming, sorry bout the newb questions
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Wait ...
I wasnt kidding
on someone it took 100 minutes for me to make him understand what does GetLocalPlayer do...
 
Level 12
Joined
Aug 20, 2007
Messages
866
Oh heh

Yeah it is a bit of an odd concept, considering in GUI you need to specify the player that each event would be working on if you did something generic (Unit - Dies)

But the code is different in JASS and you can use GetLocalPlayer() for such things (I think?)
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
I dont think registering an event for GetLocalPlayer for registering all would be ok ... (it may crash or cause big bugs)
 
Level 6
Joined
Jun 30, 2006
Messages
230
uh... there are a few things you could do with GetLocalPlayer... but only a very few. DisplayTextToPlayer, for one. The problem is that if you test whether the triggering player is equal to the GetLocalPlayer, it will trigger on one computer. So, if there is any data in the trigger which gets sent over the network... bad idea.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Ew

That's not good, so I suppose GetLocalPlayer() would be a function to be used sparingly, and I should probably do alot more work in JASS before trying it

Thnx for the info +rep
 
Status
Not open for further replies.
Top