| 09-11-2008, 04:33 AM | #2 |
You can only use the local variable trick once per GUI trigger a duh... -Av3n |
| 09-11-2008, 04:49 AM | #3 |
Wow. That blows freakin' monkey chunks. Real hard. ~~~ So... Is there a solution? (don't say "Lrn2JASS" :/...) |
| 09-11-2008, 04:50 AM | #4 |
Quit coding. |
| 09-11-2008, 04:54 AM | #5 |
First off, no point in making them locals, since there is no wait. Only time it would be an issue is if you have an order event trigger that over-write the variables you use. Secondly, the locals (if they did work) would not be able to be used in the loop of the group, since it is actually a seperate function without the locals, when it is converted to Jass on save. |
| 09-11-2008, 05:00 AM | #6 | |
Quote:
Ouch. So... Since this was (originally)part of my Spell Olympics submission, I should refrain from submitting? :P ~~~ I'm not sure what you're referring to by "order event trigger", but it's a spell; technically, if any other unit on the map casts it near the same time, the variables could be overwritten (perhaps that's what you're referring to). Hence the locals. No loops? That's unfortunate. I hope that doesn't crimp my style... |
| 09-11-2008, 05:02 AM | #7 |
Learn2jass. Really. It's the only way forward. |
| 09-11-2008, 05:09 AM | #8 |
Even if you did have a wait, you can always create (normal) locals anyway and then transfer the relevant data between your globals and locals before/after the wait. |
| 09-11-2008, 11:59 AM | #9 | |
Quote:
|
| 09-11-2008, 05:32 PM | #10 | ||
Quote:
Ok... How? Quote:
Y'know, you remind me more and more of Simon Cowell. If Locals = learn JASS, then I already know JASS. I just don't think I have the time to progress (nor the absolute need), so is there another "local-related" (or otherwise) bit of JASS knowledge that can help me out in this situation (and others like it)? |
| 09-11-2008, 06:30 PM | #11 |
As Av3n and Pyrogasm said, you don't even need locals (which is pretty much problem solved :P) Anyway, locals declared outside a UG loop cannot be used inside the UG loop (since the loop actions are in a separate function) Also, I think using bj_wantDestroyGroup can cause issues with other groups (if, say, you needed to use a ForGroup on the same UG twice, or in a periodic trigger) unless you set it back to false (since I don't think it's automatically reset once the ForGroup ends, you should check JASScraft/TESH function list for the approriate function, I think it's GetUnitInRangeOfLoc) |
| 09-11-2008, 06:46 PM | #12 |
Huh? How don't I need locals? (I mean, what if two casters cast it at once; one's "TempCasterPoint" is different from the other, thus breaking the spell (not to mention the "TempPoint")). Or is it instantaneous? "UG" loop... "Universal Globals"? (But yes, I've heard about this :/...) Is this the same with If/Then/Elses? (can can I re-call it as a local inside the Loop / If-Then-Else?) I've also heard various murmurings about not using "bj_wantDestroyGroup" as well, but nothing concrete. But what does JASS:GetUnitInRangeOfLoc |
| 09-11-2008, 07:35 PM | #13 | ||
UG -> Unit Group (at least that's what I recognise UG as :P), same applies with the Matching Condition part (so you can't do Unit is Enemy of (Localized global player) or something) And pretty much same thing happens with if-then-else (if you use the GUI version) - If conditions (in GUI) are handled in a separate function and, as a result, you can't use the locals there, but you could just add a few lines of custom script Code:
Custom script: if GetWidgetLife (whichUnit) > .405 then [color="DarkGreen"]//i.e. condition returns true if the unit is alive ---Insert some actions here--- Custom script: else [color="DarkGreen"]//The else declaration isn't required, unless you actually plan on having else actions ---Insert other actions here--- Custom script: endif Code:
Or is it instantaneous? Quote:
Quote:
Code:
local unit udg_UnitVar = GetTriggerUnit () ---You can do it all in one line, or define it afterwards through the GUI action--- call TriggerSleepAction (5.0) ---Or just use the Wait action :P--- Set OtherUnit = UnitVar Pick every unit in InsertGroupHere and do actions: ---Do some stuff with OtherUnit--- |
| 09-11-2008, 09:06 PM | #14 |
Using locals there will fail to do what you expect. Learn jass, or don't use locals. Simple as that. |
| 09-12-2008, 12:04 AM | #15 |
All I was saying about the "order event trigger" is that is the only place where your variables can be over-written. Each trigger will execute its actions completely until it either finishes or reaches a break. There are 2 kinds of breaks; breaks with a duration, or breaks with an event. Duration breaks are simply waits. They cause the trigger to stop executing for the desired time, and let other triggers execute. So, if your trigger doesn't have a wait, every action will be executed in order, whithout executing any other trigger. There is one exception though; when you use "event breaks" Event breaks happen when one of your actions triggers an event. In your case, issuing an order to a unit counts as an event break. In the case of an event break, it pauses the execution of the trigger, and runs the event triggers (the triggers which have the event "A unit is issued an order"). Once all those trigger finish, or they reach a duration break, it continues to execute the rest of the actions in the starting function Example: Code:
Trigger A has 8 actions, action 4 is a wait.
TriggerA
Action1
Action2
Action3
Action4 - Duration break
// pause for duration
Action5
Action6
Action7
Action8
EndTrigger
As you can see, once the wait is over, it jumps right back into the trigger and executes each one in order without executing other triggers.
Now, if we have an event break, its a little different
Trigger B runs when a unit is ordered to move, it has 2 actions, and no breaks
Trigger B
Action1
Action2
EndTrigger
TriggerC has an event break (a unit is ordered to move) at action 3 of 5
TriggerC
Action1
Action2
Action3 - Event Break
// wait for event triggers to finish or duration break.
Action4
Action5
EndTrigger
If we stuck both TriggerC and TriggerB in the same flow-chart it would look like this
TriggerC
Action1
Action2
Action3 - Event Break
TriggerB
Action1
Action2
EndTrigger
Action4
Action5
EndTrigger
As you can see, once the event was reached, TriggerB executed completely, and then the game revenrted directly back to TriggerC to finish the execution.The example shows that as long as you don't have duration breaks or event breaks, your variables won't be over-written. If you have duration breaks, you need to use locals. If you have event breaks, you can use locals, or you can trace through all your event triggers (that will be triggered by that event break) and make sure none of the variables are used in any of them. |
