• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Escaping the Operation Limit

Status
Not open for further replies.
You should be able to use a timer, group, or force as well. This is the traditional method:
JASS:
function StartNewThread takes code c returns nothing
    call ForForce(bj_FORCE_PLAYER[0], c)
endfunction

This should work so long as the GUI isn't tampered with. You can always do this as a safety measure:
JASS:
function StartNewThread takes code c returns nothing
    if bj_FORCE_PLAYER[0] == null then
        set bj_FORCE_PLAYER[0] = CreateForce()
    endif
    call ForForce(bj_FORCE_PLAYER[0], c)
endfunction

@hayaku1412: The operation limit (short: op limit) limits the number of consecutive actions on a single thread. A thread is just a sequence of functions. If you perform too many actions on the same thread (it is called, hitting the op limit), then wc3 won't be able to execute functions beyond that point (unless you start a new thread). It is kind of like "Skip Remaining Actions". The limit (according to PipeDream) is 300,000 bytecode operations (which is trivial information unless you trace the bytecode you use).

Certain functions will start a new thread, such as TriggerExecute() or ForForce(). If you use those, then you'll effectively be able to do another 300k bytecode operations before hitting the op limit (or until you start a new thread).
 
As Adiktuz said, you can pass a function into it (note that the function must be defined above the reference point).

However, his example has "call b", which iirc won't compile. However, you can still use it as input to things such as ForForce(), TimerStart(), or TriggerExecute().

Are you planning on using this for GUI? If so, you may want to post the triggers so we can weigh the options. The easiest/neatest way to do it in GUI is to just make a separate trigger with no events and execute it.
 
Level 8
Joined
Oct 12, 2011
Messages
483
Herp, where did my brain wander off to?
My triggers are these. I've been recommended to squeeze all the triggers together, so Imma try.

Edit: Does ExecuteFunc() create a new thread as well? Or is that just one of my crazy delusions?
 
Last edited:
Yes, ExecuteFunc() creates a new thread as well. It is a good option if the function is below where you are calling it from. I forgot about it. hehe.

If you want to run it on a new thread in the middle of a GUI trigger, you can do something like this:
  • -------- blah blah blah actions --------
  • Unit - Kill (Triggering unit)
  • Set TempUnit = (Triggering unit)
  • Custom script: call ExecuteFunc("MyNewThreadFunctionLalala")
  • -------- execute the function below us --------
  • Custom script: endfunction
  • -------- "endfunction" will allow us to declare a new function below --------
  • Custom script: function MyNewThreadFunctionLalala takes nothing returns nothing
  • -------- an example of declaring a function --------
  • Unit - Explode TempUnit
  • -------- you don't need endfunction at the end since the compiled code will place one already --------
 
Status
Not open for further replies.
Top