Sliding Trigger Won't Work

ShadowInTheD

Active Member
Reaction score
12
I basically have 2 triggers, one is supposed to make a wisp for each user, and set the wisp = udg_TempUnit in a loop, and it's supposed to create a repeating timer. The first trigger sets up the second. The second uses the location of udg_TempUnit to move the unit to it's location offset by 10 facing it's direction, and it's supposed to check this every 3 seconds. Is there any problems, and if so, can you help me? Thanks in advance, + Rep

EDIT: There's 2 things that aren't actually happening, the text in the second trigger isn't displaying, and the units don't slide!

Here are my 2 triggers

JASS:
function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i>I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,'ewsp',Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
set i = i + 1
endif
endloop
call StartTimerBJ(udg_Timer,true,.03)
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction</i>


JASS:
function Ice_Skating_Actions takes nothing returns nothing
local location l
local integer i = 0
local integer I = GetPlayers()
loop
exitwhen i&gt;I
set l = GetUnitLoc(udg_TempUnit<i>)
if GetTerrainTypeBJ(l) == &#039;Nice&#039; then
call SetUnitPositionLoc(udg_TempUnit<i>,PolarProjectionBJ(l,10,bj_UNIT_FACING))
set i = i + 1
call RemoveLocation(l)
call DisplayTextToForce(GetPlayersAll(),&quot;Does this work???&quot;)
endif
endloop
endfunction

//=====================================
function InitTrig_Ice_Skating takes nothing returns nothing
local trigger p = CreateTrigger()
call TriggerRegisterTimerExpireEvent(p,udg_Timer)
call TriggerAddAction(p,function Ice_Skating_Actions)
endfunction</i></i>
 

Charapanga

New Member
Reaction score
46
I dont have the editor infront of me but i think
JASS:
local integer I = GetPlayers()

does not return an integer
you might wanna change it with bj_MAX_PLAYER_SLOTS <- i'm not sure that's the right syntax, check under constants in your Function list.
 

ShadowInTheD

Active Member
Reaction score
12
I for sure know that the local integer I = GetPlayers() DOES work... it makes the wisp for the players that are playing.

EDIT: I know 2 possible things can be wrong, TempUnit isn't getting set to last created unit, or the timer isn't repeating or starting.. The text isn't displaying, so I don't know which 1 it actually is. Also, there could be something wrong with the 2nd condition checking terrain type.
 

Vetadors

New Member
Reaction score
1
There are a simple trigger u can do:
Trigger:
  • Ice Lol
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Icecrown Glacier - Ice
            • Then - Actions
              • Set Temp_Location = ((Position of Unit) offset by 10.00 towards (Facing of Unit) degrees)
              • Unit - Move (Picked unit) instantly to Temp_Location
            • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
 

ShadowInTheD

Active Member
Reaction score
12
Number 1, I wanted to do it in JASS ><, and 2, that trigger will leak... and it's not MPI... if I wanted to do it in GUI, I would have...... I want to know why the JASS trigger won't work, not an alternative.
 

darkbeer

Beer is Good!
Reaction score
84
well you shouldt use the ugly BJs and theres no need for 2 triggers^^

JASS:
function Timer takes nothing returns nothing
local location l
local integer i = 0
local integer I = GetPlayers()
loop
exitwhen i&gt;I
set l = GetUnitLoc(udg_TempUnit<i>)
if GetTerrainTypeBJ(l) == &#039;Nice&#039; then //you sure this is called &#039;Nice&#039;? xD
call SetUnitPositionLoc(udg_TempUnit<i>,PolarProjectionBJ(l,10,bj_UNIT_FACING)) //LEAAAAAAAAAAAAAAK <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" /> (polar projection creates another point that should be cleaned)
set i = i + 1
call RemoveLocation(l)
call DisplayTextToForce(GetPlayersAll(),&quot;Does this work???&quot;) //put it outside the loop to see if GetPlayers() might return 0
endif
endloop
endfunction

function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i&gt;I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,&#039;ewsp&#039;,Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
set i = i + 1
endif
endloop
call TimerStart(udg_Timer,.03,true, function Timer) //no BJ, no need for a 2nd trigger^^
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction

</i></i></i>


you really could improve this^^
mby use a group instead think its easier and makes things MUI instead of MPI :)
and i hope youre using newGen then use the global block instead of the udg_ variables^^

well i was bored so i thought i should show you how it could look like^^

JASS:
scope Sliding
//########################################################################

globals
    private group SlidingUnits  = CreateGroup()
    private timer Timer         = CreateTimer()
endglobals

private function GroupLoop takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real X = GetUnitX(u)
    local real Y = GetUnitY(u)
    
    if GetTerrainType(X,Y) == &#039;Nice&#039; then
        call SetUnitX(u, X + 10 * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        call SetUnitY(u, X + 10 * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        call BJDebugMsg(&quot;Moving &quot; + GetUnitName(u) + &quot; to 10 towards its facing&quot;)
    endif
    
    set u = null
endfunction

private function Loop takes nothing returns nothing    
    call ForGroup(SlidingUnits, function GroupLoop)
endfunction

private function Actions takes nothing returns nothing
    local integer i  = 0
    local integer I = GetPlayers()
    local real X = GetRectCenterX(bj_mapInitialPlayableArea)
    local real Y = GetRectCenterY(bj_mapInitialPlayableArea)
    local unit u
    
    loop
        exitwhen i&gt;I
        if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
            set u = CreateUnit(Player(i),&#039;ewsp&#039;,X,Y,bj_UNIT_FACING)
            call GroupAddUnit(SlidingUnits, u)
            call BJDebugMsg(&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
        endif
        set i = i + 1
    endloop
    
    set u = null
    call TimerStart(Timer,.03,true, function Loop)
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

//####################################################
endscope
 

ShadowInTheD

Active Member
Reaction score
12
Ofc, you never told me how to fix it nor what the problem was, and MUI isn't needable, and I will clean up leaks later >.>...
 

darkbeer

Beer is Good!
Reaction score
84
my bad, just used comments^^

put the Message outside the loop to see if the 2nd trigger is actually fired

check if the id of the terrain is correct! thats my guess, since GetPlayers() worked in the first trigger. (one of them should be causing the problem)

add an else to the terrain type check and under it a message.

else it should work
 

darkbeer

Beer is Good!
Reaction score
84
rofl
just tested and found out:
besides that my testing trigger worked fine.

JASS:
function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i&gt;I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,&#039;ewsp&#039;,Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
endif

set i = i + 1 &lt;-- outside if

endloop
call StartTimerBJ(udg_Timer,true,.03)
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction


</i>


move the set i = i +1 outside the if! ofc. else your loop never gets greater than GetPlayers() and finishes.

sorry always thinking too coplicated .... :banghead:
and please clean your PolarProjectionBJ leak^^

Edit.: rofl copyed wron trigger now its fine.
 

ShadowInTheD

Active Member
Reaction score
12
That wasn't even the problem.......... =( I tested it moving the i+1 thing, which would actually, never work....... it's supposed to be in the if.
 

darkbeer

Beer is Good!
Reaction score
84
i tested exactly your trigger and it worked with only changing that.

if you dont believe me add more debug messages and see for yourself.
 

ShadowInTheD

Active Member
Reaction score
12
Umm, i fucking tested it, and it fucking super lagged my comp...............................................................
 
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