- Joined
- Jan 1, 2009
- Messages
- 1,617
From the description:
Where's the fun in that?![]()
Where's the fun in doing it by hand?
From the description:
Where's the fun in that?![]()
Where's the fun in doing it by hand?![]()
That IS fun ^^
You dont have to use the compiler do you?
{}
=> Operator for array declaration::
=> Operator for methods when used outside of the structprotected
=> Keyword for functions like onInit or onDestroy (Same as private, but it could be added for senseless reasons)^
=> Operator for Exponents (2^3
-> 2 * 2 * 2
string != ""
during compile-time instead of dynamically in-game.nothing spam():
is faster to write and easier to read than function spam takes nothing returns nothing
while
, foreach
, print
, etc.)onInit
and onLoad
multiple timesGetTriggerUnit().data
."string" + integer
library libName(libRequirement1, ...2, etc.): # Comment
static integer i # A global integer, "internal" privacy
boolean spam(integer(a, b, c), real r=0): # function spam takes integer a, integer b, integer c, real r = 0 returns boolean
return a + b + c == r
nothing check():
local static integer i # A global variable privatized to this function
foreach(i, 16): # Loops i from 0 to 15, not counting 16
local integer j # A local variable declaration
foreach(j, i, 0, -1): # Loops j from i to 0, decreasing by 1 per loop
DoNothing()
onInit: # A block executed during initialization, prioritized top-first
onInit.priority: # A priority initializer, initialized before any others, prioritized with other priority onInit's top-first
"""
A multi-line block comment.
"""
# Unindenting ends any block
If you have a dictarray, you can use da[parentKey][childKey] = this. Alternatively, you can nest dictionaries to accomplish similar looking things.
h1 = Hash.new
h2 = Hash.new 66
h3 = Hash.new do |hash, key| # gets called if key is not in the hash
hash[key] = Hash.new # also returns the new hash
end
h1[:non_existant_key] #=> nil
h2[:non_existant_key] #=> 66
h3[:non_existant_key] #=> {} # a new hash
.methodHighlighting
is impossible in Notepad++ but was an easy "MARK_FOLLOWING" in jEdit.GetTriggerUnit.kill()
:
like Lua, to do that dirty work. Leave .
to the big kids.I seriously hope you don't do this.JASS:GetTriggerUnit.kill()
You should have another operator, such as:
like Lua, to do that dirty work. Leave.
to the big kids.
GetTriggerUnit().x
makes it seem that x is a member of GetTriggerUnit, which is blah.The thing is thatGetTriggerUnit().x
makes it seem that x is a member of GetTriggerUnit, which is blah.
x:y = y(x)
x:y(1) = y(x, y)
function handler takes nothing returns nothing
endfunction
function CrashGame takes nothing returns nothing
call Player(14821424) // does this crash? pretend it does if it doesn't
endfunction
globals
code handler = CrashGame
endglobals
function onInit takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
// if there's no function keyword, am I adding the handler variable or the function?
call TriggerAddAction(t, handler)
endfunction
You can't get rid of the "function" keyword for callbacks and such.
Behold: A world without the function keyword.
JASS:function handler takes nothing returns nothing endfunction function CrashGame takes nothing returns nothing call Player(14821424) // does this crash? pretend it does if it doesn't endfunction globals code handler = CrashGame endglobals function onInit takes nothing returns nothing local trigger t=CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT) // if there's no function keyword, am I adding the handler variable or the function? call TriggerAddAction(t, handler) endfunction
local integer array five[5]
local static integer array spam
to create a global that's localized to the function. This is something I've gotten a lot of use out of when building my libraries and it has a bright future because it's AWESOME. OK, maybe I had too much sugar today.We already have those![]()
Yea ur like the 3rd person saying that?
I got it man.
Two more things would be nice
-taking arrays as parameters
-local arrays
//don't mind the random syntax, just playing around
//also, normally you would do the action inside the enum-callback
//A spell action
function action nothing -> nothing
let caster=GetTriggerUnit()
let level=GetUnitAbilityLevel(caster, Id)
let range=Range(level)
GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(caster), GetUnitY(caster), range, null)
ForGroup(ENUM_GROUP, autodestroy lambda nothing -> nothing
UnitDamageTarget(caster, GetEnumUnit(), Damage(level), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
end)
end
// translated to
struct lambda_12
unit caster
integer level
real range
endstruct
globals
lambda_12 global_lambda_12
endglobals
function anonymous_function_12 takes nothing returns nothing
call UnitDamageTarget(global_lambda_12.caster, GetEnumUnit(), Damage(global_lambda_12.level), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
endfunction
function action takes nothing nothing nothing
local unit caster=GetTriggerUnit()
local integer level=GetUnitAbilityLevel(caster, Id)
local real range=Range(level)
local lambda_12 generated__1=lamda_12.create()
call GroupEnumUnitsInRange(ENUM_GROUP, GetUnitX(caster), GetUnitY(caster), range, null)
set generated__1.caster=caster
set generated__1.level=level
set generated__1.range=range
set global_lambda_12=generated__1
call ForGroup(ENUM_GROUP, function anonymous_function_12)
call generated__1.destroy()
endfunction
//now without autodestroy
function adder integer x -> Function<integer,integer>
return lambda integer y -> integer
return x+y
end
end
//...
let f=adder(7)
//...
print(f(5)) #-> 12
//again, actions of a spell
function Actions nothing -> nothing
local autodestroy event_data event=GetEventData()
event.caster.do_some_damage(event.target)
create_some_effect_in_between(event.caster, event.target)
if event.level then
//generated: event.destroy()
return
end
event.caster.do_circle_damage(event.target_x, event.target_y)
//generated: event.destroy()
end
return event.level
call event.destroy()
return event.level
function bla takes nothing returns nothing
local level=44
local dynamic_array a=[1,2,level]
endfunction
// compiled to
function bla takes nothing returns nothing
local level=44
local dynamic_array a=dynamic_array.create().set(0, 1).set(1,2).set(2,level)
endfunction
interface Array
method set takes integer index, integer value returns Array
method get takes integer index returns integer
endinterface
set
returns Array
or the implementation this
it's possible to chain the methods like above and create variable length arraysstruct dynamic_array implements Array
static hashtable storage=InitHashtable()
method set takes integer index, integer value returns thistype
call SaveInteger(storage, integer(this), index, value)
return this
endmethod
method get takes integer index returns integer
return LoadInteger(storage, integer(this), index)
endmethod
endstruct
local dynamic_array a=[1]
local tree_based_dynamic_array b=[1,2]
local dynamic_array c=[6,7]
local fixed_length_array d=fixed_length_array.new(5, [8,7])
local dynamic_array e=[5=>6, 7=>8]
//...
local dynamic_array a=dynamic_array.new().set(0,1)
local tree_based_dynamic_array b=tree_based_dynamic_array.new().set(0,1).set(1,2)
local dynamic_array c=dynamic_array.new().set(0,6).set(1,7)
local fixed_length_array d=fixed_length_array.new(5, standart_array.new().set(0,8).set(1,7))
local dynamic_array e=dynamic_array.new().set(5,6).set(7,8)