| 11-10-2007, 08:08 PM | #1 |
I finished my code and tried it, and it didn't work. After putting messages around the code I found out that the trigger just isn't being started by the event. I origrinally had this: JASS:function InitTrig_Endless_Arena_x takes nothing returns nothing set gg_trg_Endless_Arena_x = CreateTrigger( ) call TriggerRegisterLeaveRectSimple( gg_trg_Endless_Arena_x, Rect(-6000.00, -6100.00, 6000.00, 6100.00) ) call TriggerAddAction( gg_trg_Endless_Arena_x, function Trig_Endless_Arena_x_Actions ) set gg_trg_Endless_Arena_x = null endfunction But that didn't work. So i changed it to use a region instead of a rectangle: JASS:function InitTrig_Endless_Arena_x takes nothing returns nothing local region Map_Bounds = CreateRegion() call RegionAddRect(Map_Bounds, Rect(-6000,-6100,6000,6100)) set gg_trg_Endless_Arena_x = CreateTrigger( ) call TriggerRegisterLeaveRegion ( gg_trg_Endless_Arena_x, Map_Bounds, null) call TriggerAddAction( gg_trg_Endless_Arena_x, function Trig_Endless_Arena_x_Actions ) call BJDebugMsg ("This trig works?") endfunction But it still didn't work. Can anyone tell me how to fix this? +rep Here's the whole code: JASS:function Endless_Arena_x_Actions takes unit u, location pos returns nothing local integer count = 0 local integer tempI local unit Otheru local location Otherpos = GetUnitLoc(Otheru) local real tempx local real tempxo local real tempy local real tempyo call BJDebugMsg ("THis works?") loop set count = count + 1 if udg_ship[count] == u then set tempI = (R2I(count/2-0.6)) set Otheru = udg_ship[tempI+(3-(count-tempI))] exitwhen udg_ship[count] == u endif endloop if udg_curangle[count] < 270 and udg_curangle[count] > 90 then if GetUnitFacing(u) > 90 and GetUnitFacing(u) < 270 then set tempx = (-1*GetLocationX(pos)) + GetLocationX(pos) - GetLocationX(Otherpos) set tempy = GetLocationY (pos) set tempxo = -1 * GetLocationX(pos) set tempyo = GetLocationY (pos) elseif GetUnitFacing(u) > 270 and GetUnitFacing(u) < 90 then set tempx = (-1*GetLocationX(pos)) + GetLocationX(pos) - GetLocationX(Otherpos) + (RSignBJ(GetLocationX(pos))*1500) set tempy = GetLocationY (pos) set tempxo = -1 * GetLocationX(pos) + (RSignBJ(GetLocationX(pos))*1500) set tempyo = GetLocationY (pos) endif elseif udg_curangle[count] > 270 and udg_curangle[count] < 90 then if GetUnitFacing(u) > 270 and GetUnitFacing(u) < 90 then set tempx = (-1*GetLocationX(pos)) + GetLocationX(pos) - GetLocationX(Otherpos) set tempy = GetLocationY (pos) set tempxo = -1 * GetLocationX(pos) set tempyo = GetLocationY (pos) elseif GetUnitFacing(u) > 90 and GetUnitFacing(u) < 270 then set tempx = (-1*GetLocationX(pos)) + GetLocationX(pos) - GetLocationX(Otherpos) + (RSignBJ(GetLocationX(pos))*1500) set tempy = GetLocationY (pos) set tempxo = -1 * GetLocationX(pos) + (RSignBJ(GetLocationX(pos))*1500) set tempyo = GetLocationY (pos) endif endif call SetUnitPosition (Otheru, tempxo, tempyo) call SetUnitPosition (u, tempx, tempy) set Otherpos = null set Otheru = null endfunction function Trig_Endless_Arena_x_Actions takes nothing returns nothing call Endless_Arena_x_Actions ( GetTriggerUnit(), GetUnitLoc(GetTriggerUnit()) ) call BJDebugMsg ("how bout?") endfunction //=========================================================================== function InitTrig_Endless_Arena_x takes nothing returns nothing local region Map_Bounds = CreateRegion() call RegionAddRect(Map_Bounds, Rect(-6000,-6100,6000,6100)) set gg_trg_Endless_Arena_x = CreateTrigger( ) call TriggerRegisterLeaveRegion ( gg_trg_Endless_Arena_x, Map_Bounds, null) call TriggerAddAction( gg_trg_Endless_Arena_x, function Trig_Endless_Arena_x_Actions ) call BJDebugMsg ("This trig works?") endfunction |
| 11-10-2007, 11:38 PM | #2 |
JASS:function InitTrig_Endless_Arena_x takes nothing returns nothing set gg_trg_Endless_Arena_x = CreateTrigger( ) call TriggerRegisterLeaveRectSimple( gg_trg_Endless_Arena_x, Rect(-6000.00, -6100.00, 6000.00, 6100.00) ) call TriggerAddAction( gg_trg_Endless_Arena_x, function Trig_Endless_Arena_x_Actions ) set gg_trg_Endless_Arena_x = null // ERROR endfunction Do NOT null global triggers. Do NOT null ANYTHING unless YOU declared it as LOCAL before that JASS:public function InitTrig takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterLeaveRectSimple( trig, Rect(-6000.00, -6100.00, 6000.00, 6100.00) ) call TriggerAddAction( trig, function Trig_Endless_Arena_x_Actions ) set trig = null // now it is OK because trig is local endfunction EDIT: try this |
| 11-11-2007, 12:53 AM | #3 |
Yeah... except for the fact that nulling a trigger does not mean it doesn't still have events/conditions/actions. The reference to the trigger just no longer exists whilst the trigger still does, so that is evidently not his problem. This is the real error: JASS:local unit Otheru local location Otherpos = GetUnitLoc(Otheru) Additionally, this will cause compile errors, as the variable "u" doesn't exist: JASS:exitwhen udg_ship[count] == u Last, you're referencing the variable pos a lot in the second half of the trigger. That variable also doesn't exist and will cause compile errors. |
| 11-11-2007, 02:36 AM | #4 |
I wrongly assumed he was trying to call that trigger from another one and that is because it failed, so I did not bother to read on.. Well maybe it is not his main error but it is still an error, and my statement still stands: Do NOT null global triggers. |
| 11-11-2007, 03:26 AM | #5 |
Ya, didn't realize that was a global (basically my second Jass and the tutorial told me to null trigs like that) so I'll make sure I remember that. And thanks for pointing that out Pyro, I see now what I did wrong, before this I had to move my local decs from inside the ifs at the bottom so before "Otheru" would have been set properly but now it isn't. Oh, and u and pos are variables they are the parameters of the trigger it self. Again, thanks +rep! |
| 11-11-2007, 03:31 AM | #6 |
Shit, son. You can't do that. You cannot pass arguments to a trigger's actionfunc. It WILL crash. |
| 11-11-2007, 08:25 AM | #7 |
nulling global variables doesnt do anything bad, you just have to make sure you wont use it in the future, or if you do to make sure it is nulled |
| 11-11-2007, 09:48 AM | #8 | ||
Quote:
Quote:
Nulling WE generated globals IS a bad thing, ALWAYS. And you DON'T have to null globals not even "after" you use them. |
| 11-11-2007, 10:41 AM | #9 |
no no 100% this event may be bugged ! (i have (but found a work around way) this issue in TcX) yes it may happen what LeaveReg will not trigger. =\ idk why maybe it not allow to move more than once units from 1 to the other region (which does have this event). what i mean yes i may happen what leave event may fail ! (it's proofed) it's kind a random bug. |
| 11-11-2007, 12:10 PM | #10 | |
The problem here is far from being related to nulling a global, but using a global there... unless you want to mess with the trigger later it just doesn't make any sense to use a global there, unless you blindly follow world editor's silly suggestions as to how to use custom text. Quote:
The real sentence would be "using WE generated globals is lame" |
| 11-11-2007, 12:18 PM | #11 | |
When things can create problems they are dangerous, when things are dangerous they are bad. It does not matter if chance of a problem is small, as long as there is a chance a problem is still a problem. Quote:
true. true. @Salbrismind If you want to learn how to avoid using WE generated stuff read this. |
| 11-11-2007, 04:15 PM | #12 | |
Quote:
I can't use the parameters? If thats what you mean, your wrong, I finished the code and it works. And no worry guys I don't ever plan to use WE defaulted code for trigs. Just I got lazy... |
| 11-11-2007, 07:23 PM | #13 |
Oh; I didn't see you had two separate functions with only two slightly different names. In that case, your code is OK. |
