Narks
Vastly intelligent whale-like being from the stars
- Reaction score
- 90
make the language like java, since vjass has a lot of similarities to it
//////////////////////////////////////////
// Typecasting 2.0.1
// by kingking
//
// This library provides some type
// converting functions.
//
// ====================================
// Functions provided :
// ====================================
// Agent2Widget(agent) -> widget
// Agent2Group(agent) -> group
// Agent2Trigger(agent) -> trigger
// Agent2Timer(agent) -> timer
// Agent2Location(agent) -> location
// Agent2Effect(agent) -> effect
// Agent2Unit(agent) -> unit
// Agent2Item(agent) -> item
// Widget2Unit(widget) -> unit
// Widget2Destructable(widget) -> destructable
// Widget2Item(widget) -> item
//
// Due to the usage of CovertFogState in hashtable, I2X
// is available again.
//
// Int2Widget(integer) -> widget
// Int2Destructable(integer) -> destructable
// Int2Item(integer) -> item
// Int2Unit(integer) -> unit
// Int2Ability(integer) -> ability
// Int2Timer(integer) -> timer
// Int2Trigger(integer) -> trigger
// Int2TriggerCondition(integer) -> triggercondition
// Int2TriggerAction(integer) -> triggeraction
// Int2Force(integer) -> force
// Int2Group(integer) -> group
// Int2Location(integer) -> location
// Int2Rect(integer) -> rect
// Int2Sound(integer) -> sound
// Int2Effect(integer) -> effect
// Int2UnitPool(integer) -> unitpool
// Int2ItemPool(integer) -> itempool
// Int2Quest(integer) -> quest
// Int2QuestItem(integer) -> questitem
// Int2DefeatCondition(integer) -> defeatcondition
// Int2TimerDialog(integer) -> timerdialog
// Int2Leaderboard(integer) -> leaderboard
// Int2Multiboard(integer) -> multiboard
// Int2MultiboardItem(integer) -> multiboarditem
// Int2Trackable(integer) -> trackable
// Int2Dialog(integer) -> dialog
// Int2Button(integer) -> button
// Int2TextTag(integer) -> texttag
// Int2Ubersplat(integer) -> ubersplat
// Int2Region(integer) -> region
// Int2FogState(integer) -> fogstate
// Int2FogModifier(integer) -> fogmodifier
//////////////////////////////////////////
library Typecasting requires Array
define DATA = Array{}
public procedure Typecast{parent, return}
ptype = lower{parent}
rtype = lower{return}
write
public $rtype$ $parent$2$return$($ptype$ object)
DATA.set$parent$(0, object)
return DATA.get$return$(0)
Typecast{"Agent", "Widget"}
Typecast{"Agent", "Group"}
Typecast{"Agent", "Trigger"}
Typecast{"Agent", "Timer"}
Typecast{"Agent", "Location"}
Typecast{"Agent", "Effect"}
Typecast{"Agent", "Unit"}
Typecast{"Agent", "Item"}
Typecast{"Widget", "Unit"}
Typecast{"Widget", "Destructable"}
Typecast{"Widget", "Item"} //The best one
public procedure TypecastI2X{name}
type = lower{name}
write
public $type$ Int2$name$(int id)
DATA.setFogState(0, ConvertFogState(id))
return DATA.get$name$(0)
TypecastI2X{"Unit"}
TypecastI2X{"Effect"}
TypecastI2X{"Trigger"}
TypecastI2X{"Timer"}
TypecastI2X{"Widget"}
TypecastI2X{"Group"}
TypecastI2X{"Location"}
TypecastI2X{"Item"}
TypecastI2X{"Destructable"}
TypecastI2X{"TriggerCondition"}
TypecastI2X{"TriggerAction"}
TypecastI2X{"Force"}
TypecastI2X{"Rect"}
TypecastI2X{"Sound"}
TypecastI2X{"UnitPool"}
TypecastI2X{"ItemPool"}
TypecastI2X{"Quest"}
TypecastI2X{"QuestItem"}
TypecastI2X{"Trackable"}
TypecastI2X{"Dialog"}
TypecastI2X{"Button"}
TypecastI2X{"TextTag"}
TypecastI2X{"Image"}
TypecastI2X{"Ubersplat"}
TypecastI2X{"Region"}
TypecastI2X{"FogModifier"}
[...]
[...]
- Textmacros totally redefined to give maximum functionality. You can basically define your own compile-time rules now.
John Foderaro said:Lisp is a programmable programming language.
Placing a "$" token within a ""-type string will treat the following segment as an I2S or R2S or basic string with concatenation.
print "$bottles bottles of beer on the wall, $bottles bottles of beer, take one down, pass it around, $(bottles - 1) bottles of beer on the wall"
//versus
call BJDebugMsg(I2S(bottles) + "bottles bottles of beer on the wall, " + I2S(bottles) + " bottles of beer, take one down, pass it around, " + I2S(bottles - 1) + " bottles of beer on the wall")
library KillSpell:
define:
private integer SPELL_ID = 039;A000039;
boolean Actions():
if GetSpellAbilityId()!=SPELL_ID:
return false
unit toKill=GetSpellTargetUnit()
KillUnit(toKill)
return false
onInit:
trigger t=CreateTrigger()
TriggerAddCondition(t,Condition(Actions))
integer i=0
while i < bj_MAX_PLAYERS:
TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT)
i++
t=null
#luck
library T32:
/*
This will print "3; 2; 1" every 0.03125 seconds:
struct myStruct:
procedure PeriodicLoop():
write:
print "$this"
T32{"PeriodicLoop"}
onInit:
thistype::1.startPeriodicLoop()
thistype::2.startPeriodicLoop()
thistype::3.startPeriodicLoop()
*/
define public T32_PERIOD = 0.03125
global:
public constant int T32_FPS = R2I(1 / T32_PERIOD)
public int T32_Tick = 0
trigger trig = CreateTrigger()
public procedure T32(periodicName):
include:
thistype next
thistype prev
public nothing start$periodicName$():
debug:
if this.prev != 0 or thistype::0.next == this:
print "T32 ERROR: Struct #$this had start$periodicName$ called while already running!"
return
thistype::0.next.prev = this
this.next = thistype::0.next
thistype::0.next = this
public nothing stop$periodicName$():
debug:
if this.prev == 0 and thistype::0.next != this:
print "T32 ERROR: Struct #$this had stop$periodicName$ called while not running!"
return
this.prev.next = this.next
this.next.prev = this.prev
this.prev = 0
onInit:
TriggerAddCondition(trig, Condition(lambda boolean:
readonly thistype this = thistype::0.next //Yeah, it's a module-readonly local variable
while this != 0:
$periodicName${}
this = this.next
))
onInit:
TimerStart(CreateTimer(), T32_PERIOD, true, lambda nothing:
Tick++
TriggerEvaluate(trig)
)
#endluck