Trying to Learn..

Exide

I am amazingly focused right now!
Reaction score
448
Ok. I'm trying to learn JASS, but no matter how much I stare at the same line I can't seem to understand what's wrong with it.
I took an existing GUI trigger and converted into custom text, and tried to change my global variables into local ones. Apparently I made one or a few errors somewhere..
This is what I got:

JASS:

function Trig_Hero_Respawning_Copy_Func027C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Hero_Respawning_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not Trig_Hero_Respawning_Copy_Func027C() ) then
        return false
    endif
    return true
endfunction

function Trig_Hero_Respawning_Copy_Func004001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 1 )
endfunction

function Trig_Hero_Respawning_Copy_Func005001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 2 )
endfunction

function Trig_Hero_Respawning_Copy_Func006001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 3 )
endfunction

function Trig_Hero_Respawning_Copy_Func007001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 4 )
endfunction

function Trig_Hero_Respawning_Copy_Func008001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 5 )
endfunction

function Trig_Hero_Respawning_Copy_Func009001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 6 )
endfunction

function Trig_Hero_Respawning_Copy_Func010001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 7 )
endfunction

function Trig_Hero_Respawning_Copy_Func011001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) == 8 )
endfunction

function Trig_Hero_Respawning_Copy_Func012001 takes nothing returns boolean
    return ( GetHeroLevel(GetTriggerUnit()) >= 9 )
endfunction

function Trig_Hero_Respawning_Copy_Actions takes nothing returns nothing
    local player Owner = GetOwningPlayer(GetTriggerUnit())
    local unit Respawn_Hero[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetTriggerUnit()
    if ( Trig_Hero_Respawning_Copy_Func004001() ) then
        set udg_Respawn_Time = 20
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func005001() ) then
        set udg_Respawn_Time = 25
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func006001() ) then
        set udg_Respawn_Time = 30
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func007001() ) then
        set udg_Respawn_Time = 35
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func008001() ) then
        set udg_Respawn_Time = 40
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func009001() ) then
        set udg_Respawn_Time = 45
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func010001() ) then
        set udg_Respawn_Time = 50
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func011001() ) then
        set udg_Respawn_Time = 55
    else
        call DoNothing(  )
    endif
    if ( Trig_Hero_Respawning_Copy_Func012001() ) then
        set udg_Respawn_Time = 60
    else
        call DoNothing(  )
    endif
    call DisplayTimedTextToForce( udg_All_Players, 10.00, " " )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + "'s Hero has been killed!|r" ) ) )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + ( "'s Hero will respawn in " + ( I2S(udg_Respawn_Time) + " seconds!|r" ) ) ) ) )
    call StartTimerBJ( udg_Respawn_Timer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], false, I2R(udg_Respawn_Time) )
    call CreateTimerDialogBJ( udg_Respawn_Timer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], ( "|cff32cd32" + "Hero respawn in:|r" ) )
    call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), Owner )
    call TriggerSleepAction( I2R(udg_Respawn_Time) )
    call TimerDialogDisplayForPlayerBJ( false, GetLastCreatedTimerDialogBJ(), GetOwningPlayer(GetTriggerUnit()) )
    call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )
    local point Location = GetRectCenter(gg_rct_Hero_Respawn_Region)
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetTriggerUnit()), udg_Location, 0.00 )
    call ReviveHeroLoc( Respawn_Hero[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], udg_Location, true )
    call RemoveLocation( Location)
endfunction

//===========================================================================
function InitTrig_Hero_Respawning_Copy takes nothing returns nothing
    set gg_trg_Hero_Respawning_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Respawning_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Hero_Respawning_Copy, Condition( function Trig_Hero_Respawning_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Hero_Respawning_Copy, function Trig_Hero_Respawning_Copy_Actions )
endfunction


Um.. I really have no idea what I'm doing. :p
Maybe you guys can read this gibberish and help me?
Thank you. :)
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
Ouch. GUI conditions. What are the errors. What line(s) are they on?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
As an example,
JASS:
    if ( Trig_Hero_Respawning_Copy_Func005001() ) then
        set udg_Respawn_Time = 25
    else
        call DoNothing(  )
    endif

and the function that goes with it, could be written as:

JASS:
    if GetHeroLevel(GetTriggerUnit()) == 2 then
        set udg_Respawn_Time = 25
    endif


Which would already remove plenty of functions, plenty of calls, be cleaner and more readable.

Even shorter, and faster too, would be:
JASS:
    if GetHeroLevel(GetTriggerUnit()) == 1 then
        set udg_Respawn_Time = 20
    elseif GetHeroLevel(GetTriggerUnit()) == 2 then
        set udg_Respawn_Time = 25
    elseif GetHeroLevel(GetTriggerUnit()) == 3 then
        set udg_Respawn_Time = 30
    elseif GetHeroLevel(GetTriggerUnit()) == 4 then
        set udg_Respawn_Time = 35
    elseif GetHeroLevel(GetTriggerUnit()) == 5 then
        set udg_Respawn_Time = 40
    elseif GetHeroLevel(GetTriggerUnit()) == 6 then
        set udg_Respawn_Time = 45
    elseif GetHeroLevel(GetTriggerUnit()) == 7 then
        set udg_Respawn_Time = 50
    elseif GetHeroLevel(GetTriggerUnit()) == 8 then
        set udg_Respawn_Time = 55
    else
        set udg_Respawn_Time = 60
    endif


Even better: store the level in a variable, and test the variable instead of asking the level every time...


Though, the final optimization is to use:
set udg_Respawn_Time = 15 + 5 * GetHeroLevel(GetTriggerUnit())



> local point Location = GetRectCenter(gg_rct_Hero_Respawn_Region)

You can not declare locals somewhere in the middle.
All of those declarations must come at the beginning.
 
Reaction score
456
I hardly can read that, and this is not the best way learning JASS. :)
I edit this post when I've optimized the code a bit.

EDIT://I wasn't fast enough it seems ;D

JASS:
set udg_Respawn_Time = 15 + 5 * GetHeroLevel(GetTriggerUnit())


But if the hero level is greater than 8, the respawn time should be 60, but that formula makes it greater than 60 if the level is 10.
 

Exide

I am amazingly focused right now!
Reaction score
448
Second Re-make, still doesn't work but I think it looks like it SHOULD work, but then again what do I know..:

JASS:

function Trig_Hero_Respawning_Copy_Func027C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Hero_Respawning_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not Trig_Hero_Respawning_Copy_Func027C() ) then
        return false
    endif
    return true
endfunction

function Trig_Hero_Respawning_Copy_Actions takes nothing returns nothing
    local player Owner = GetOwningPlayer(GetTriggerUnit())
    local unit Respawn_Hero = GetTriggerUnit()
    local point Location = GetRectCenter(gg_rct_Hero_Respawn_Region)
    local timer Respawn_Timer = 15 + 5 * GetHeroLevel(GetTriggerUnit())
    call DisplayTimedTextToForce( udg_All_Players, 10.00, " " )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + "'s Hero has been killed!|r" ) ) )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + ( "'s Hero will respawn in " + ( I2S( Respawn_Timer) + " seconds!|r" ) ) ) ) )
    call StartTimerBJ( Respawn_Timer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], false, I2R( Respawn_Timer) )
    call CreateTimerDialogBJ( Respawn_Timer, ( "|cff32cd32" + "Hero respawn in:|r" ) )
    call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), Owner )
    call TriggerSleepAction( I2R( Respawn_Time) )
    call TimerDialogDisplayForPlayerBJ( false, GetLastCreatedTimerDialogBJ(), GetOwningPlayer(GetTriggerUnit()) )
    call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetTriggerUnit()), Location, 0.00 )
    call ReviveHeroLoc( Respawn_Hero, Location, true )
    call RemoveLocation( Location)
endfunction

//===========================================================================
function InitTrig_Hero_Respawning_Copy takes nothing returns nothing
    set gg_trg_Hero_Respawning_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Respawning_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Hero_Respawning_Copy, Condition( function Trig_Hero_Respawning_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Hero_Respawning_Copy, function Trig_Hero_Respawning_Copy_Actions )
endfunction
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Seems to me to be the name of the trigger.

It's the name of the function.
Yes, you can change that.
Just make sure to never have two or more functions with the same name.


The remaining conditions functions could also be simplified to
return trigger unit is a hero and player number of owner <= 4
Or, actually, why not just register 5 events, one for each player of interest?


You're using a lot of "GetOwningPlayer(GetTriggerUnit())"... though it is already stored in a variable.
I'd suggest to use it.

You're setting the revive point to the local Location, but revive the Hero at the global "udg_Location", which I guess is the center of the map?

> GetLastCreatedTimerDialogBJ

Store that in a variable, before waiting.
 

Exide

I am amazingly focused right now!
Reaction score
448
I'm trying my best, but it seems like the more I "fix" it, the more errors I get. :/
This is what it looks like now:

JASS:

function Trig_Hero_Respawning_Copy_Func027C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Hero_Respawning_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not Trig_Hero_Respawning_Copy_Func027C() ) then
        return false
    endif
    return true
endfunction

function Trig_Hero_Respawning_Copy_Actions takes nothing returns nothing
    local player Owner = GetOwningPlayer(GetTriggerUnit())
    local unit Respawn_Hero = GetTriggerUnit()
    local point Location = GetRectCenter(gg_rct_Hero_Respawn_Region)
    local timer Respawn_Time = 15 + 5 * GetHeroLevel(Respawn_Hero())
    call DisplayTimedTextToForce( udg_All_Players, 10.00, &quot; &quot; )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( &quot;|cff32cd32&quot; + ( GetPlayerName(Owner) + &quot;&#039;s Hero has been killed!|r&quot; ) ) )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( &quot;|cff32cd32&quot; + ( GetPlayerName(Owner) + ( &quot;&#039;s Hero will respawn in &quot; + ( I2S( Respawn_Time) + &quot; seconds!|r&quot; ) ) ) ) )
    call StartTimerBJ( Respawn_Timer, false, I2R( Respawn_Time) )
    call CreateTimerDialogBJ( Respawn_Timer, ( &quot;|cff32cd32&quot; + &quot;Hero respawn in:|r&quot; ) )
    call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), Owner)
    call TriggerSleepAction( I2R( Respawn_Time) )
    call TimerDialogDisplayForPlayerBJ( false, GetLastCreatedTimerDialogBJ(), Owner)
    call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )
    call PanCameraToTimedLocForPlayer( Owner), Location, 0.00 )
    call ReviveHeroLoc( Respawn_Hero, Location, true )
    call RemoveLocation( Location)
endfunction

//===========================================================================
function InitTrig_Hero_Respawning_Copy takes nothing returns nothing
    set gg_trg_Hero_Respawning_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Respawning_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Hero_Respawning_Copy, Condition( function Trig_Hero_Respawning_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Hero_Respawning_Copy, function Trig_Hero_Respawning_Copy_Actions )
endfunction


I did a little thinking of my own and instead of using the variable for Owner of Unit (Triggering Unit) (Respawn_Hero), I skipped the whole unit -part and used the variable for: (Owner of Unit (Triggering Unit) 'Owner'. I figured that might work better.
Also, I'm having problems with Respawn_Time and Respawn_Timer.
I want them to be local variables, but I don't know how to set a local Countdown Timer variable.

Respawn_Time = Integer variable
Respawn_Timer = Timer (Array) variable.

I want to make them both local (non-array) variables, but don't know how.
 

SFilip

Gone but not forgotten
Reaction score
634
Well nobody seems to notice, but...
local point Location = GetRectCenter(gg_rct_Hero_Respawn_Region)
Jass doesn't have a type called "point"
local location Location = GetRectCenter(gg_rct_Hero_Respawn_Region)
 
S

SquirrelyCat

Guest
Ok, when you declare the last local, local point location ..... when i load up JassCraft and did syntax checker it says that's an undefined type, i know location is a type thou, did you mean local location point?? No idea if JassCraft is crazy...or YOU are XD (darn it someone got there first!)

I'm still looking in on it thou, keep up ur hard work, and another strategy to fixing stuff is to take off the BJ's at the end of those calls, and if the syntax is do-able for you, than go ahead and use the non-BJ thing, although sometimes it's best to stick with BJ, cause some of them i've no idea how to do.
 

Exide

I am amazingly focused right now!
Reaction score
448
Thanks both of you.
Yes, it is I that is crazy, not JassCraft. :p
I thought a point variable would be point.. I was wrong. :p
Sadly, though, I get the same error even after changing that line:

JASS:

    local location Location = GetRectCenter(gg_rct_Hero_Respawn_Region)


Error:
Line 414: Expected a reserved type or handle type

I think I heard Jass is case sensitive, so 'local location Location' Shouldn't be a problem in any way, right?

EDIT: Oh, I forgot to ask: What are BJs? What does BJ stand for?
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
'point' is not a type. It should be:

JASS:


A few tips on locals:

1) It is common practice to make all of your locals entirely lowercase (or at least begin with a lowercase letter). Consider:

JASS:


becomes:

JASS:
local location loc


2) You declare them 'local' <type> -name-.

JASS:
local &lt;location&gt; -loc-


The most commonly used types being:



There are more, but those are the most common.

EDIT: Damn, I spent too long on that post -.-

EDIT 2:And BJ is Blizzard Jass I think. They are fluff functions, that are made by Blizzard, which call natives. The reason we hate them is that we can easily just call the natives ourselves, saving processing power. The only BJ's I use are the Alliance ones.
 
S

SquirrelyCat

Guest
BJ = opposite of effecient XD

Are there any cases (besides the ones you said) where BJ's would be good (like quests or something?)?
 

Exide

I am amazingly focused right now!
Reaction score
448
I feel I need to update this as I update my trigger:

JASS:

function Trig_Hero_Respawning_Copy_Func027C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Hero_Respawning_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not Trig_Hero_Respawning_Copy_Func027C() ) then
        return false
    endif
    return true
endfunction

function Trig_Hero_Respawning_Copy_Actions takes nothing returns nothing
    local player owner = GetOwningPlayer(GetTriggerUnit())
    local unit hero = GetTriggerUnit()
    local location loc = GetRectCenter(gg_rct_Hero_Respawn_Region)
    local timer time = 15 + 5 * GetHeroLevel(hero())
    call DisplayTimedTextToForce( udg_All_Players, 10.00, &quot; &quot; )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( &quot;|cff32cd32&quot; + ( GetPlayerName(owner) + &quot;&#039;s Hero has been killed!|r&quot; ) ) )
    call DisplayTimedTextToForce( udg_All_Players, 10.00, ( &quot;|cff32cd32&quot; + ( GetPlayerName(owner) + ( &quot;&#039;s Hero will respawn in &quot; + ( I2S( time) + &quot; seconds!|r&quot; ) ) ) ) )
    call StartTimerBJ( Respawn_Timer, false, I2R( time) )
    call CreateTimerDialogBJ( Respawn_Timer, ( &quot;|cff32cd32&quot; + &quot;Hero respawn in:|r&quot; ) )
    call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), owner)
    call TriggerSleepAction( I2R( time) )
    call TimerDialogDisplayForPlayerBJ( false, GetLastCreatedTimerDialogBJ(), owner)
    call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )
    call PanCameraToTimedLocForPlayer( owner), loc, 0.00 )
    call ReviveHeroLoc( hero, loc, true )
    call Removelocation( loc)
endfunction

//===========================================================================
function InitTrig_Hero_Respawning_Copy takes nothing returns nothing
    set gg_trg_Hero_Respawning_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Respawning_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Hero_Respawning_Copy, Condition( function Trig_Hero_Respawning_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Hero_Respawning_Copy, function Trig_Hero_Respawning_Copy_Actions )
endfunction


I changed all locals to use lower case, and I change their names, like: 'Respawn_Time' to 'time'.

How can I remove BJs without causing further confusion and errors?



JASS:

    call DestroyTimerDialogBJ( GetLastCreatedTimerDialog() )


-It can't be that simple, can it?

Oh, and changing local variable Location's name into loc, seems to have solved THAT problem.. For some weird reason. :p Thanks.
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
My suggestion: NewGen + TESH for NewGen. Look up the functions, and write this stuff yourself. Just changing BJ's is too hard, and I'm lazy. To find out what a BJ does with TESH, just ctrl+click it.
 

Exide

I am amazingly focused right now!
Reaction score
448
I have no idea what you just said. :p

Let's skip BJs for a while and focus on getting my trigger to work, shall we? :)

JASS:

    local timer time = 15 + 5 * GetHeroLevel(hero())


Generates an Error: Expected '

How can I add a local variable for Respawn_Timer?
Respawn_Timer = Timer (Array) variable.
I don't want it to be Array.

EDIT: In my GUI trigger, with global variables: 'time' was an integer variable, and 'Respawn_Timer' was an 'Timer' with array.
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
A timer is an object. That should be:

JASS:
local timer t=CreateTimer()

Then if you wanna set a time to it:

JASS:
call TimerStart(t,&lt;your time&gt;,false,function &lt;yourfunction&gt;)


<yourfunction> will be called after the duration.
 

Exide

I am amazingly focused right now!
Reaction score
448
I don't even know what <myfunction> is..
This is what my trigger looked like to start with:

Code:
Hero Respawning
    Events
        Unit - A unit Dies
    Conditions
        ((Triggering unit) is A Hero) Equal to True
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                (Owner of (Triggering unit)) Equal to Player 4 (Purple)
                (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
    Actions
        Custom script:   local player udg_DeadHero_Owner
        Set DeadHero_Owner = (Owner of (Triggering unit))
        Set Respawn_Hero[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
        If ((Hero level of (Triggering unit)) Equal to 1) then do (Set Respawn_Time = 20) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 2) then do (Set Respawn_Time = 25) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 3) then do (Set Respawn_Time = 30) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 4) then do (Set Respawn_Time = 35) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 5) then do (Set Respawn_Time = 40) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 6) then do (Set Respawn_Time = 45) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 7) then do (Set Respawn_Time = 50) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Equal to 8) then do (Set Respawn_Time = 55) else do (Do nothing)
        If ((Hero level of (Triggering unit)) Greater than or equal to 9) then do (Set Respawn_Time = 60) else do (Do nothing)
        Game - Display to All_Players for 10.00 seconds the text: <Empty String>
        Game - Display to All_Players for 10.00 seconds the text: (|cff32cd32 + ((Name of (Owner of (Triggering unit))) + 's Hero has been killed!|r))
        Game - Display to All_Players for 10.00 seconds the text: (|cff32cd32 + ((Name of (Owner of (Triggering unit))) + ('s Hero will respawn in  + ((String(Respawn_Time)) +  seconds!|r))))
        Countdown Timer - Start Respawn_Timer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in (Real(Respawn_Time)) seconds
        Countdown Timer - Create a timer window for Respawn_Timer[(Player number of (Owner of (Triggering unit)))] with title (|cff32cd32 + Hero respawn in:|r)
        Countdown Timer - Show (Last created timer window) for DeadHero_Owner
        Wait (Real(Respawn_Time)) seconds
        Countdown Timer - Hide (Last created timer window) for (Owner of (Triggering unit))
        Countdown Timer - Destroy (Last created timer window)
        Set Location = (Center of Hero Respawn Region <gen>)
        Camera - Pan camera for (Owner of (Triggering unit)) to Location over 0.00 seconds
        Hero - Instantly revive Respawn_Hero[(Player number of (Owner of (Triggering unit)))] at Location, Show revival graphics
        Custom script:   call RemoveLocation(udg_Location)

The idea was to set the integer (now named 'time') according to the Hero's level, and then set the timer window to 'time', wait 'time' seconds, and then revive the hero and remove the timer window.
 

0zaru

Learning vJASS ;)
Reaction score
60
> local timer time = 15 + 5 * GetHeroLevel(hero())

Actually hero() is a function or a local ?
 

Exide

I am amazingly focused right now!
Reaction score
448
I have no idea. That was AceHart's idea of 'easy coding', I believe. :p
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
There is no function Hero() unless you declare it. Btw, a local won't have those brackets "()" behind.

Go with

JASS:
set udg_Respawn_Time = 15 + 5 * GetHeroLevel(GetTriggerUnit())


as already posted quite a few times in this thread
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top