Ok, I'm now implementing ZINC syntax in wc3jass.com. Please post code in ZINC here in order to check if it's highlighting it properly.
Thanks.
Thanks.
library HelloWorld
{
function onInit()
{
BJDebugMsg("Hello World");
}
} library Bottles99
{
/* 99 Bottles of beer sample,
prints the lyrics at: [url]http://99-bottles-of-beer.net/lyrics.html[/url]
*/
function onInit()
{
string bot = "99 bottles";
integer i=99;
while (i>=0)
{
BJDebugMsg(bot+" of beer on the wall, "+bot+" of beer");
i=i-1;
if (i== 1) bot = "1 bottle";
else if (i== 0) bot = "No more bottles";
else bot = I2S(i)+" bottles";
//Lazyness = "No more" is always capitalized.
if(i>=0)
{
BJDebugMsg("Take one down and pass it around, "+bot+" of beer on the wall.\n");
}
}
BJDebugMsg("Go to the store and buy some more, 99 bottles of beer on the wall.");
}
} library Test
{
function test1()
{
//Also refer to the CountUnitsInGroup example ...
TimerStart(CreateTimer(), 5.0, false, function() {
BJDebugMsg("5 seconds since you called test1");
});
}
type unitFunc extends function(unit);
function AllyEnemyFunctionPicker(player p, unit u, unitFunc F, unitFunc G)
{
if (IsUnitAlly(u, p) ) {
F.evaluate(u);
} else {
G.evaluate(u);
}
}
/* those things up there are just the function pointers example */
function test2(unit u)
{
unitFunc F, G;
F = function(unit u) {
BJDebugMsg("We are torturing "+GetUnitName(u)+" again");
KillUnit(u);
};
G = function(unit u) { SetWidgetLife(u, 100); };
AllyEnemyFunctionPicker( Player(0), u, F, G);
// will torture the unit if it is an ally, or heal it otherwise.
// notice this does the same as the function pointers example.
}
}
library Test
{
//a function type with a single unit argument
type unitFunc extends function(unit);
//a function type with two integer arguments that returns boolean
type evFunction extends function(integer,integer) -> boolean;
function TortureUnit(unit u)
{
BJDebugMsg(GetUnitName(u)+" is being tortured!");
KillUnit(u);
}
function HealUnit(unit u)
{
SetWidgetLife(u, 1000);
}
/* This function calls F(u) if the unit is an ally or G(u) if the unit is an enemy
the example sucks as it is much slower than an if-else but should be good
to explain it... */
function AllyEnemyFunctionPicker(player p, unit u, unitFunc F, unitFunc G)
{
if (IsUnitAlly(u, p) ) {
F.evaluate(u);
} else {
G.evaluate(u);
}
}
function test(unit u)
{
// We are using the functions as arguments here...
AllyEnemyFunctionPicker( Player(0), u, TortureUnit, HealUnit );
// will torture the unit if it is an ally, or heal it otherwise.
}
}