• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

[Trigger] Problem wit a trigger - cannot be turned on.

Status
Not open for further replies.
Hello all, chobibo made a trigger for me used for the spell mind control, but the prob is that the MC main trigger indicates error with function MC_callback. Chobibo says there is no problem in his world editor to disable and enable the trigger, but I get an error. Do you know what this might be caused of?
http://www.hiveworkshop.com/forums/pastebin.php?id=mcgujl
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I tested it again, you were right they did cause errors, I stand corrected.

EDIT: The triggers no longer work properly, MC_Owner isn't saved on the hashtable, have you edited the triggers?
 
I tested it again, you were right they did cause errors, I stand corrected.

EDIT: The triggers no longer work properly, MC_Owner isn't saved on the hashtable, have you edited the triggers?

I put the MC_owner in correct hashtable and that is not the problem.

It could be that when compiling the map, it can not find the function when it compiles that triger as the MC_callback has not yet been compiled.
edit: yep, isn't it obvious that the editor does not recognzie MC_callback. The question is, why? Is something wrong with my editor?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
No you didn't.
  • MC main
    • Events
      • Unit - Shadow Hunter 0008 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Control
    • Actions
      • Custom script: local unit udg_MC_Target=GetSpellTargetUnit()
      • Custom script: local player udg_MC_Owner=GetOwningPlayer(udg_MC_Target)
      • Custom script: local timer t=CreateTimer()
      • Custom script: set udg_MC_TimerKey=GetHandleId(t)
      • Hashtable - Save Handle OfMC_Target as 1 of MC_TimerKey in MC_HT
      • Hashtable - Save Handle OfMC_Target as 2 of MC_TimerKey in MC_HT <----
      • Game - Display to (All players) the text: (|c00FF0000The Shadow Hunter took controll over|r + (Name of (Triggering unit)))
      • Unit - Change ownership of MC_Target to (Triggering player) and Change color
      • Custom script: call TimerStart(t,udg_MC_Duration[GetUnitAbilityLevel(GetTriggerUnit(),'A008')],false,function MC_callback)
      • Custom script: set t=null
      • Custom script: set udg_MC_Target=null
      • Custom script: set udg_MC_Owner=null
  • MC onCast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Control
    • Actions
      • Custom script: local unit udg_MC_Target=GetSpellTargetUnit()
      • Custom script: local player udg_MC_Owner=GetOwningPlayer(udg_MC_Target)
      • Custom script: local timer t=CreateTimer()
      • Custom script: set udg_MC_TimerKey=GetHandleId(t)
      • Custom script: //call DisplayTimedTextToPlayer(Player(0),0,0,60.00,"Id is "+I2S(udg_MC_TimerKey))
      • Hashtable - Save Handle OfMC_Target as 1 of MC_TimerKey in MC_HT
      • Hashtable - Save Handle OfMC_Owner as 2 of MC_TimerKey in MC_HT <----
      • Custom script: call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",udg_MC_Target,"origin"))
      • Unit - Change ownership of MC_Target to (Triggering player) and Change color
      • Custom script: call UnitAddAbility(udg_MC_Target,'Abun')
      • Custom script: call TimerStart(t,udg_MC_Duration[GetUnitAbilityLevel(GetTriggerUnit(),'A000')],false,function MC_callback)
      • Custom script: set t=null
      • Custom script: set udg_MC_Target=null
      • Custom script: set udg_MC_Owner=null
Look at that.

And the original map had that function declared...

  • MC Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- duration per level --------
      • Set MC_Duration[1] = 10.00
      • Set MC_Duration[2] = 15.00
      • -------- hashtable --------
      • Custom script: set udg_MC_HT=InitHashtable()
      • Custom script: endfunction
      • -------- ----------------------------------------------------------------------------------------------- --------
      • -------- Spell timer callback --------
      • -------- ----------------------------------------------------------------------------------------------- --------
      • Custom script: function MC_callback takes nothing returns nothing
      • Set MC_TimerKey = (Key (Expiring timer))
      • Set MC_Target = (Load 1 of MC_TimerKey in MC_HT)
      • Set MC_Owner = (Load 2 of MC_TimerKey in MC_HT)
      • Unit - Change ownership of MC_Target to MC_Owner and Change color
      • Custom script: call UnitRemoveAbility(udg_MC_Target,'Abun')
      • Custom script: call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",udg_MC_Target,"origin"))
      • Custom script: call DestroyTimer(GetExpiredTimer())
      • Custom script: call RemoveSavedHandle(udg_MC_HT,udg_MC_TimerKey,1)
      • Custom script: call RemoveSavedHandle(udg_MC_HT,udg_MC_TimerKey,2)
      • Custom script: set udg_MC_Target=null
      • Custom script: set udg_MC_Owner=null
I told you to copy the Init first.
 
Last edited:
Level 22
Joined
Sep 24, 2005
Messages
4,821
  • Your Trigger
    • Hashtable - Save Handle OfMC_Target as 1 of MC_TimerKey in MC_HT
    • Hashtable - Save Handle OfMC_Target as 2 of MC_TimerKey in MC_HT
  • Original
    • Hashtable - Save Handle OfMC_Target as 1 of MC_TimerKey in MC_HT
    • Hashtable - Save Handle OfMC_Owner as 2 of MC_TimerKey in MC_HT
If you still can't see it, then I can't help you any further.
 
Fuck!, I thought you will say something different than that. I told you this is not the problem, i changed it already, this do not define your function.
I put the MC_owner in correct hashtable and that is not the problem.


line 63: expected function
call TimerStart(t,udg_MC_Duration[GetUnitAbilityLevel(GetTriggerUnit(),'A008')],false,function MC_callback)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
It is just like maker and chobibo have said. The function is not declared before the function that is using it. Put function MC_callback in the map header or make a new trigger and put it above the trigger that the timer that calls it is in.

If you don't understand how to do that there are a few tutorials on functions usage in GUI triggers. Look at them. I believe i covered a small thing on them in my tutorial things a guier should know but i am not really sure.
 
Level 7
Joined
Mar 6, 2006
Messages
282
I remember not understanding the same thing OP, so I'll draw it out for you a bit.

When you save your map, the editor changes all of your triggers into JASS, in one big long file, called war3map.j

So if you have:

Trigger1 ( init )
Trigger2 ( call myfunc )
Trigger3 ( myfunc )

Then that's the order that they will be written, in war3map.j

NOW THEN, your problem is that the editor says it does not recognize a function. First, you must know that JASS is read from top to bottom, so let's look at this again:

Trigger1 ( init )
Trigger2 ( call myfunc ) <---- that trigger doesn't know what 'myfunc' is !
Trigger3 ( myfunc )

Because it's ABOVE the func.

So to fix this, you need to put your function above the place that you're calling it. Like Maker suggested, you could put your function in the map header, which is written above ALL your triggers in war3map.j

In the trigger editor, on the folder tree thing, click the actual map file (with the .w3x), and you can type code in there. That's the map header, and it gets written first.
 
Status
Not open for further replies.
Top