Why make #luck? That's stupid.
It can be used by other potential compilers to know that the code within gets ignored so it can be sent to the right compiler, rather than displaying errors 'cause it doesn't know the code.
Why make #luck? That's stupid.
The rest of the readability likely has to do with TimerUtils being multi-flavored. Have you ever tried reading it in vJass? It's a mess.
some of it looks nice but seeing as it's in luck which isn't entirely understood...won't bother updating until backwards compatible with vjass comes. in the meantime, i see nothing wrong with you writing it up...not like they suddenly gonna release jasshelper your version with jngp if they weren't releasing it before with updates not going to now.
i agree but that's because of the static if fad. static ifs are a joke. they're entirely pointless.
what's the point of stocking up tons of code in a map only to have zero fun factor in the map? more code does not equal more fun. what each coder needs is the best bits of code and throw away the unnecessary parts.
nothing damageUnits(unit sourceUnit, real damageAmount):
UnitDamageTarget(sourceUnit, GetEnumUnit(), damageAmount, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
boolean onEffect():
unit castingUnit = GetTriggerUnit()
GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(castingUnit), GetUnitY(castingUnit), 500.0, null)
ForGroup(ENUM_GROUP, function damageUnits(castingUnit, 200.0))
nothing onInit():
trigger mainTrigger = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(mainTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
TriggerAddCondition(mainTrigger, Condition(function onEffect))
globals
/* Obviously, these globals would need unique and retarded names to prevent possible overwriting. */
unit callbackTemporaryUnit = null
real callbackTemporaryReal = 0.0
endglobals
function damageUnits takes nothing returns nothing
local unit sourceUnit = callbackTemporaryUnit
local real damageAmount = callbackTemporaryReal
call UnitDamageTarget(sourceUnit, GetEnumUnit(), damageAmount, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
set sourceUnit = null
endfunction
/* Or: */
function damageUnits takes nothing returns nothing
call UnitDamageTarget(callbackTemporaryUnit, GetEnumUnit(), callbackTemporaryReal, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
endfunction
function onEffect takes nothing returns boolean
local unit castingUnit = GetTriggerUnit()
call GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(castingUnit), GetUnitY(castingUnit), 500.0, null)
set callbackTemporaryUnit = castingUnit
set callbackTemporaryReal = 200.0
call ForGroup(ENUM_GROUP, function damageUnits)
set castingUnit = null
return false
endfunction
function onInit takes nothing returns nothing
local trigger mainTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(mainTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(mainTrigger, Condition(function onEffect))
set mainTrigger = null /* Nulling static triggers isn't really needed, but doing it wouldn't hurt either. */
endfunction
Awesome and infinite times better than what I suggested (ironically, I had even screwed up the example code, but fixed it right before you posted).As far as anonymous functions are concerned, they will certainly borrow locals (readonly) from the containing function. So the "lambda nothing" and "lambda boolean" convention is a lot neater than a verbose way of pretending to add parameters to that code.
Okay, I have no idea what I was thinking when I wrote that. You're right, it only supports function and static methods. Well, Zinc also supports function pointers in conjunction with anonymous functions, but I have no idea how it will be done in Luck.Zinc does anonymous (non-static) methods? It only does static methods as code arguments from all the tests I performed on it. Vex had said he would add locals as readonly to the anonymous functions declared within that function, but he never got around to it.
type myFunction extends function (unit);
function onInit() {
myFunction callback = function(unit whichUnit) {
KillUnit(whichUnit);
BJDebugMsg("Killing a " + GetUnitName(whichUnit));
};
callback.evaluate(CreateUnit(Player(0), 039;hfoo039;, 0., 0., 0.));
}
while true
i--
until i == 0
#Compiles to:
loop
set i = i - 1
exitwhen i == 0
endloop
#Or you could write:
while i != 0:
i--
lib MyLib:
class myClass:
codeblock myCustomLoop(int x):
x = 15
while x <= 0:
codeblock.include() # I am not sure how I want to include the user's block, this kind of fits
x--
onInit:
t = trigger.create()
myClass.myCustomLoop(int i):
t.onPlayerChatEvent(i.player, "", false)
t.onPlayerUnitEvent(i.player, EVENT_PLAYER_UNIT_LOADED)
what is the problem with static ifs in a pre-made system?
obviously they make little sense in your own map, unless you plan on extensive changes in the future
but still, they are not pointless
and whats it matter what the .j looks like once compiled - who needs to read it anyway?
type testMethod extends function (integer);
struct testStruct extends array {
private static testMethod anon;
private static method onInit() {
thistype this = testStruct(0x7FFFFFFF);
anon = method() {
BJDebugMsg("Calling an anonymous method; struct index: " + I2S(integer(this)) + "!");
};
anon.evaluate(this);
}
}