• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Can you do any of this? (in standard JASS)

Status
Not open for further replies.
Level 10
Joined
Jan 28, 2009
Messages
442
- Remove a triggeraction ?
- Call a local triggeraction ?

I want to call certain functions dynamically (without manually calling functions). And use of triggeractions are my best bet on how to achieve this.
Yeah, you're shaking your head at me, but I'll continue anyway.

I have an unfinished function that does nothing at the moment and goes like this:

JASS:
function ReadString takes triggeraction ReadAction returns nothing
endfunction

I wanted it to "call ReadAction", which I tried, even though I felt certain that it wouldn't work :p
(And I felt stupid while trying, and I still do)

So, do you think I am a helpable person? If so, please enlighten me.
 
Level 10
Joined
Jan 28, 2009
Messages
442
Okay, well I think locals are all I need for this fortunately. It's just important to me that I don't have a ton of triggers, so as long as the trigger is temporary, it's good.
I don't know if local means that it's temporary because I'm very new in the world of JASS.

What kind of handle is "code"? Can you explain it for a GUI-user?


I am using a loop that checks substrings from a string used to store a multitude of data as an alternative to using an array. The loop is supposed to do some action based on external factors and the signs it finds in the string during the loop. So, let's say we have 3 different actions. Examples: 1: (create MyItem(IntegerB) for (hero); 2: (create unit of (MyUnitType[IntegerB]) at TempLoc; 3: Set Current life of (hero) to R2I(IntegerB)

The variable actions are defined before the loop starts. Now this is all theoretical, but I want to find a way to actually do this. But I think that maybe it could be done by creating and removing triggers (or using local triggers). So, I will experiment with that if no better sollution comes up. Thanks.
 
So that is what you wanted? To run a function dynamically?
Anyways, create a trigger variable via the variable editor and change the code to this;

JASS:
function RunFunc takes code c returns nothing
    call TriggerClearActions(udg_YOUR_TRIGGER_VAR)
    call TriggerAddAction(udg_YOUR_TRIGGER_VAR, c)
    call TriggerExecute(udg_YOUR_TRIGGER_VAR)
endfunction

And a code variable is not a handle, it's a function. So you would use this like

call RunFunc(function FuncName)
 
Status
Not open for further replies.
Top