Yes, it's a function called Current Order which returns a String:
-
Conditions
-
(Current order of (Triggering unit)) Equal to (Order(stop))
Also, TrainingDetection is pretty simple to use:
vJASS:
GetCurrentTrainedObjectId takes unit whichbuilding returns integer
GetLastTrainedObjectId takes unit whichbuilding returns integer
GetBuildTimeRemaining takes unit whichbuilding returns real
// It will return the remaining time for a unit being trained.
// Sadly the native only works for normal units, not for heroes.
// For anything but a normal unit it will return 0.
// The slot number might not be identical with the true position in order-queue.
// Only the size number is identical. But the true slot positon might change.
// With knowing the size you might loop through the queue each get each element.
GetTrainingQueueSize takes unit whichbuilding returns integer
GetTrainedObjectId takes unit whichbuilding, integer whichslot returns integer
ReOrderTrainingQueue takes unit building returns nothing
// ReOrder will internally stop and start trainings to simulate cancel at front,
// be aware of that. After cleaning the queue, all units will have correct position in queue.
// (works with GetCleanTrainingQueue, see later)
CancelTrainingBack takes unit building returns nothing
// Back works same as using order native with CANCEL-id
CancelTrainingFront takes unit building returns nothing
// Front will internally stop and start trainings to simulate cancel at front, be aware of that.
CountFinishedUnits takes unit whichbuilding returns integer
CountFinishedTechs takes unit whichbuilding returns integer
CountFinishedUpgrades takes unit whichbuilding returns integer
GetCleanTraningQueue takes unit building, boolean keepFirst returns nothing
// After calling it the building will have all traingings canceled.
// set keepFirst "true" to avoid cancelling the first unit being trained.
Those are all of the functions that you would use. The first text you see in all white is the function name (
GetCurrentTrainedObjectId), the next line after that which says "
takes" tells you what variables you need to put into the
(parenthesis
) of said function. The greyed out text in front of the double slashes // is literally a comment from the author of this code. It's no different than the Comment action that we often use in the Trigger Editor to leave ourselves notes. After "
takes" you can see "
returns" which tells you what variable type gets returned back to you (if any) after the function is finished running, which you could then store in a variable of the same variable type. For example,
GetTrainingQueueSize returns the number of units being trained, which is an Integer value. So you could store that in an Integer variable like so:
-
Actions
-
Set Variable MyBuilding = (The building unit)
-
Custom script: set udg_MyInteger = GetTrainingQueueSize( udg_MyBuilding )
MyInteger is an Integer variable that you would create in the Variable Editor. You can reference it like any other Integer variable after setting it's value in the Custom Script.
Here's another example, let's say that we wanted to tell our building to cancel the first unit being trained:
-
Actions
-
Set Variable MyBuilding = (The building unit)
-
Custom script: call CancelTrainingFront( udg_MyBuilding )
This orders the building to cancel the first unit being trained (the one in the front of the training queue).
This system could probably solve your problem in a couple of Actions. All it takes is basic knowledge of how functions work in Jass, which is pretty easy to learn, especially with how many tutorials are on Hive.