Tyrulan
Ultra Cool Member
- Reaction score
- 37
What is the proper syntax to declare a type?
Thanks.
JASS:
type someFunc extends myFunc
Thanks.
type someFunc extends myFunc
type text extends string
// Function/method:
local text name = "Hello" // (I THINK this is how you use something like this; I've never found a use for these)
library Test
type TortureUnit extends TortureUnit
type HealFunc extends HealUnit
function TortureUnit takes unit u returns nothing
call BJDebugMsg("Torturing Unit")
endfunction
function HealUnit takes unit u returns nothing
call BJDebugMsg("Healing Unit")
endfunction
function AllyOrEnemy takes player p, unit u, TortureFunc c, HealFunc c2 returns nothing
if (IsUnitAlly(u, p)) then
// c.evaluate(u)
else
// c2.evaluate(u)
endif
endfunction
function Conditions takes nothing returns boolean
if (GetSpellAbilityId() == 039;A004039;) then
return true
endif
return false
endfunction
function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
call AllyOrEnemy (GetOwningPlayer(caster), target, TortureUnit, HealUnit)
endfunction
//===========================================================================
function InitTrig_sandbox takes nothing returns nothing
set gg_trg_sandbox = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_sandbox, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_sandbox, Condition(function Conditions))
call TriggerAddAction( gg_trg_sandbox, function Actions )
endfunction
endlibrary
type someFunc extends function(args) -> returnType;
type hi extends function()
//! zinc
....
//! endzinc
//! zinc
library Test
{
type unitFunc extends function(unit);
function TortureUnit(unit u)
{
debug BJDebugMsg(GetUnitName(u)+" is being tortured!");
AddSpecialEffectTarget("Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl", u, "overhead");
}
function HealUnit(unit u)
{
debug BJDebugMsg(GetUnitName(u)+" is being healed!");
SetWidgetLife(u, 1000);
}
function AllyEnemyFunctionPicker(player p, unit u, unitFunc Torture, unitFunc Heal)
{
if (IsUnitAlly(u, p))
{
Heal.evaluate(u);
} else
{
Torture.evaluate(u);
}
}
function spellIDMatch() -> boolean
{
return (GetSpellAbilityId() == 039;A004039;);
}
function test()
{
unit target = GetSpellTargetUnit();
AllyEnemyFunctionPicker( Player(0), target, TortureUnit, HealUnit );
/*Will torture the unit if it is an ally, or heal it otherwise.*/
}
function onInit()
{
trigger t = CreateTrigger();
TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT);
TriggerAddCondition(t, Condition(function spellIDMatch));
TriggerAddAction(t, function test);
}
}
//! endzinc