• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] JASS sliding triggers

Status
Not open for further replies.
Level 9
Joined
May 30, 2008
Messages
430
Those are mine current sliding triggers i am trying to make them work for now after this i will try to make the sliding thing

JASS:
function MasterSlideTimer takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,0.25,false,function MasterSlide)
    set t = null
endfunction

JASS:
function MasterSlide takes nothing returns nothing
    local unit udg_kittys
    local unit u 
    local timer t = GetExpiredTimer()
    local real lx 
    local real ly 
    local location tempPoint
    local integer i = 1
    local unit group = udg_kittys
    loop
        exitwhen i > 12
        set u = (udg_kittys[i])
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)        
        set tempPoint = GetUnitLoc(u)
        if (GetTerrainType (lx, ly) == 'Nice' ) and (IsUnitInGroup (udg_kittys[i])),( SlidingAlive == true) then
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )
    endloop
        //null all
        set u = null
        call DestroyTimer(t)
        set t = null
        call RemoveLocation (tempPoint)
endfunction

how to fix my current code :con:
Edited:1
 
Last edited:
Level 6
Joined
Apr 16, 2007
Messages
177
JASS:
if (GetTerrainType (lx, ly) == 'Nice' ) And (IsUnitInGroup (udg_kittys[GetForLoopIndexA()]), SlidingAlive = true) then
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )

where's the endif?

"And" -> and

if you're allready using JASS; why are you still using bj_forLoopAIndex?
JASS:
  local integer i = 1
  loop
        exitwhen i > 12

then replace all GetForLoopIndexA() with i.
 
Level 9
Joined
May 30, 2008
Messages
430
now looks like this
JASS:
function MasterSlide takes nothing returns nothing
    local unit udg_kittys
    local unit u 
    local timer t = GetExpiredTimer()
    local real lx 
    local real ly 
    local location tempPoint
    local integer i = 1
    local unit group = udg_kittys
    loop
        exitwhen i > 12
        set u = (udg_kittys[i])
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)        
        set tempPoint = GetUnitLoc(u)
        if (GetTerrainType (lx, ly) == 'Nice' ) and (IsUnitInGroup (udg_kittys[i])),( SlidingAlive == true) then
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )
    endloop
        //null all
        set u = null
        call DestroyTimer(t)
        set t = null
        call RemoveLocation (tempPoint)
endfunction
but still give me error at this line
JASS:
if (GetTerrainType (lx, ly) == 'Nice' ) and (IsUnitInGroup (udg_kittys[i])),( SlidingAlive == true) then

and where to put this endif
 
Level 6
Joined
Jul 22, 2008
Messages
243
The endif is supposed to put an end to the if so to speak.

if(Argument)
Stuff to happend goes here
endif

So, it works like the loop / endloop
 
Level 9
Joined
May 30, 2008
Messages
430
The endif is supposed to put an end to the if so to speak.

if(Argument)
Stuff to happend goes here
endif

So, it works like the loop / endloop

i get that end if is like endloop but where to put it if some one don't help me learn JASS i will never learn it (i need to watch how the things are working not to find out how they are working. You know it's easy to work when u how the things are done than to try to done them for first time without watching how others done them)

Edit: there i go and
JASS:
function MasterSlide takes nothing returns nothing
    local unit udg_kittys
    local unit u 
    local timer t = GetExpiredTimer()
    local real lx 
    local real ly 
    local location tempPoint
    local integer i = 1
    local group SlidingAlive
    loop
        exitwhen i > 12
        set u = udg_kittys[i]
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)        
        set tempPoint = GetUnitLoc(u)
        if (GetTerrainType (lx, ly) == 'Nice') "and" (IsUnitInGroup ((udg_kittys[i]), SlidingAlive), == true) then
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )
            exitwhen false
    endloop
    //null all
    set u = null
    call DestroyTimer(t)
    set t = null
    call RemoveLocation (tempPoint)
endfunction
i am stuck with "syntax error" at this line
JASS:
if (GetTerrainType (lx, ly) == 'Nice') "and" (IsUnitInGroup ((udg_kittys[i]), SlidingAlive), == true) then
 
Last edited:
Level 11
Joined
May 16, 2007
Messages
288
JASS:
if (GetTerrainType (lx, ly) == 'Nice') "and" (IsUnitInGroup ((udg_kittys[i]), SlidingAlive), == true) then
     call DisplayTextToForce( GetPlayersAll(), "This is a message" )
endif

That's all, every time you make an "if" statement (don't know if this is the correct word to use), you have to write "endif" at the end of it or it will bug.

Also, remove the "exitwhen", I'm not sure, but I think it only works for loops, not ifs.
 
Level 9
Joined
May 30, 2008
Messages
430
the jass craft say that the problem is here
JASS:
if (GetTerrainType (lx, ly) == 'Nice') and (IsUnitInGroup ((udg_kittys[i]), SlidingAlive)), == true) then
don't say nothing about missing endif or other things the whole script look like this if some one can fix it ok if you think i have to put "exitwhen, endif" just chek for your self
 
Level 3
Joined
Mar 25, 2009
Messages
32
You don't need to use exitwhen because its just for looping not inside if, you need endif. i don't really sure what is 'nice'?
 
Level 9
Joined
May 30, 2008
Messages
430
I will try to give all the info i can if somthing is not clear please tell me

JASS:
function MasterSlideTimer takes nothing returns nothing
    local timer t = CreateTimer()
//i am not familiar with timer but the problem here is with function
//i dunno how to define functions 
    call TimerStart(t,0.25,false,function MasterSlide)
    set t = null
endfunction

JASS:
//This will be trigger that activate the sliding triggers (they will run every 0.02 seconds)
function MasterSlide takes nothing returns nothing
    local unit array udg_kittys //are the units that will slide set with GUI in map initialization
    local unit u //the first selected unit in the loop
    local timer t = GetExpiredTimer() //the timer from function 1
    local real lx //unit x for GetTerrainType 
    local real ly //unit y for GetTerrainType
    local location tempPoint //current position of the unit that i will chek
    local integer i = 1 //the loop
    local group SlidingAlive //if the unit is alive is in this group declared in another GUI trigger but u dudes may give me JASS line for if unit is alive
    loop
        exitwhen i > 12
        set u = udg_kittys[i]
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)        
        set tempPoint = GetUnitLoc(u)
        //down lines chek if terrain type is ice and if the unit is in unit group sliding alive (if the unit is alive)
        //u can help me to make the second part somthing like if unit is alive or somthing
        if (GetTerrainType (lx, ly) == 'Nice') and (IsUnitInGroup ((udg_kittys[i]), SlidingAlive)), == true) then //here it give me syntax error dunno why
            //here i am cheking if this work at all
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )
            exitwhen false
    endloop
    //null all
    set u = null
    call DestroyTimer(t) //destroyng the timer from first function
    set t = null //null the timer from first function
    call RemoveLocation (tempPoint)
endfunction

I dunno if i can and how to merge those both triggers into one and to make the timer trigger to activate the second trigger
 
Level 9
Joined
May 30, 2008
Messages
430
My trigger look like this now, don't give any errors and don't type any messages (don't start at all in the game i think)
JASS:
//This will be trigger that activate the sliding triggers (they will run every 0.02 seconds)
function MasterSlide takes nothing returns nothing
    local unit array udg_kittys //are the units that will slide, set with GUI in map initialization
    local unit u //the first selected unit in the loop
    local timer t = GetExpiredTimer() //the timer from function 1
    local real lx //unit x for GetTerrainType
    local real ly //unit y for GetTerrainType
    local location tempPoint //current position of the unit that i will chek
    local integer i = 1 //the loop
    local group SlidingAlive //if the unit is alive is in this group declared in another GUI trigger but u dudes may give me JASS line for if unit is alive
    loop
        exitwhen i > 12
        set u = udg_kittys[i]
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)
        set tempPoint = GetUnitLoc(u)
        //down lines chek if terrain type is ice and if the unit is in unit group sliding alive (if the unit is alive)
        //u can help me to make the second part somthing like if unit is alive or somthing
        if (GetTerrainType (lx, ly) == 'Nice') then //here it give me syntax error dunno why
            //here i am cheking if this work at all
            call DisplayTextToForce( GetPlayersAll(), "This is a message" )
        endif
    endloop
    //null all
    set u = null
    call DestroyTimer(t) //destroyng the timer from first function
    set t = null //null the timer from first function
    call RemoveLocation (tempPoint)
endfunction

function MasterSlideTimer takes nothing returns nothing
    local timer t = CreateTimer()
//i am not familiar with timer but the problem here is with function
//i dunno how to define functions
    call TimerStart(t,0.03,false, function MasterSlide)
    set t = null
endfunction

how to start my trigger in game i chek the box where it say run at map initialization:zip:

Edit: the trigger look like this now and it work. Now the sliding part remain i will try to make it tommorow


JASS:
//This will be trigger that activate the sliding triggers (they will run every 0.02 seconds)
globals
//    unit array udg_kittys //are the units that will slide, set with GUI in map initialization
    unit u //the first selected unit in the loop
    timer t = GetExpiredTimer() //the timer from function 1
    real lx //unit x for GetTerrainType
    real ly //unit y for GetTerrainType
    location tempPoint //current position of the unit that i will chek
    integer i = 1 //the loop
    group SlidingAlive //if the unit is alive is in this group declared in another GUI trigger but u dudes may give me JASS line for if unit is alive
endglobals

function Trig_MasterSlide_Actions takes nothing returns nothing
    set i = 1    
    loop
        exitwhen i > 12
        set u = udg_kittys[i]
        set lx = GetUnitX(u)
        set i = i+1
        set ly = GetUnitY(u)
        set tempPoint = GetUnitLoc(u)
        //down lines chek if terrain type is ice and if the unit is in unit group sliding alive (if the unit is alive)
        //u can help me to make the second part somthing like if unit is alive or somthing
        if (GetTerrainType (lx, ly) == 'Nice') then //here it give me syntax error dunno why
            //here i am cheking if this work at all
            call DisplayTextToForce( GetPlayersAll(), "It work" )
        else
            call DisplayTextToForce( GetPlayersAll(), "No work" )
        endif
    endloop
    //null all
    set u = null
    call DestroyTimer(t) //destroyng the timer from first function
    set t = null //null the timer from first function
    call RemoveLocation (tempPoint)
endfunction

function InitTrig_MasterSlide takes nothing returns nothing
local timer t = CreateTimer()
    set gg_trg_MasterSlide = CreateTrigger( )
    call TimerStart(t,0.03,true, function Trig_MasterSlide_Actions)
    set t = null
endfunction


any ideas how to make my unit slide forward with it's current speed. I search for such a function but there are few that are "call UnitMoveToAsProjectileGen(m, arc,x2,y2,null,z2)" and i don't get nothing from these is there another MoveUnit functions
 
Last edited:
Status
Not open for further replies.
Top