• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[JASS] Inheritance and using type "code"

Status
Not open for further replies.
[SOLVED] Inheritance and using type "code"

edit: Solved, great solutions guys, thanks =)

type code is something I just don't understand. What kinds of things can be assigned like this? I am trying to program a constant filterfunc but in the laws of precedence I know of, the function it's referencing must be declared first. Does using code to run a function bypass the laws of precedence (similar to native ExecuteFunc)?
 
Last edited:
Nope, it will say undeclared function. The only way to bypass it is ExecuteFunc or maybe TriggerEvaluate/Execute (but you should use Evaluate).

Ex: This might work:
JASS:
globals
    trigger runSomeStuff = CreateTrigger()
endglobals
function Hehe takes nothing returns nothing
    call TriggerEvaluate(runSomeStuff)
endfunction

//Stuffs trig
function Stuff takes nothing returns boolean
    call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\DragonHawkMissile\\DragonHawkMissile.mdl",0,0))
    return false
endfunction
function InitTrig_doingStuff takes nothing returns nothing
    call TriggerAddCondition(runSomeStuff,Condition(function Stuff))
//just be sure that the trigger has the condition added sometime before Hehe is called
endfunction

=)
 
Laws of inheritance? I guess that's not what you mean. Inheritance is when a type "inherits" another types' properties, such as the type "unit" has all the properties of the type "widget", which has all the properties of a "handle", because they extend each other.

I'm not sure if there is a technical term for the way functions need to be below the function they are calling, but it's certainly nothing to do with inheritance.

Anyway, as for what you're trying to do, it's impossible to make a constant boolexpr with a value assigned to it. Just make it a normal one and assign it to Filter(function YourFunction) in your initialisation function.
 
I'm not sure if there is a technical term for the way functions need to be below the function they are calling, but it's certainly nothing to do with inheritance.
Sorry, precedence. That's what I meant to say.

Also, I'm editing the war3map.j file, so I can click and drag the functions above the globals block. I just don't know if that's allowed... it wouldn't be fair if it's not allowed because you can reference the useless blizzard.j file from the globals block but not your own, more efficient ones?
 
Inheritance is when a type "inherits" another types' properties, such as the type "unit" has all the properties of the type "widget", which has all the properties of a "handle", because they extend each other.

Inheritance is when you have a rich uncle who likes you. =D

Anyway, jokes aside, I guess that could work. But you could always just set them on init (and place your functions in the map header) if you really need to. There is not much harm in setting globals later than when they were declared. =)

Either that or you can try using:
JASS:
//! import "c:\myScript.j"

Although, I've never messed around with that. But that should allow you to use them wherever, whether it be in the globals block or not.
 
Status
Not open for further replies.
Top