Skip to content

CNC Generals Zero hour Lua Functions

MetaIdea edited this page Jul 13, 2021 · 4 revisions

Calling original map script actions and conditions:

SMT internally introduces a wrapper function that allows to call any map script action and condition in it's lua scripts. A complete list is available HERE.

Note: There are dozens of usefull new lua utility functions build out of these functions useable and can be found in EssentialScripts.lua and MetaModScripts.lua in Source/Scripts. The MetaModScripts.lua comes from a old project called meta mod and consists out of over 10.000 lines of usefull code you can use as well.

Other new extra functions SMT introduces:

Function Return Values Example Comment
ExecuteAction(...) Use any original map script action.
EvaluateCondition(...) bool Use any original map script condition.
SetScriptTimer(time,function,loops) -
print(text) - Print to ingame console
log(text) - Log to meta.log file
ObjectGetPosition(object) x,y,z coord numbers
ObjectGetDistance(object) distance number
ObjectGetRotation(object) angle number
GetGroundHeight(x,y) height number
ObjectSetPosition(object,x,y) -
ObjectSetRotation(object,angle) -
GetObjectType(object) string
ObjectTestKindOf(object,kindof) bool
GetObjectBuildCost(object) number
GetObjectHealth(object) number
GetObjectEditorSorting(object) string
GetObjectSide(object) string
IterateObjectType(index) string object type

Experimental or unfinished

Function Return Values Example Comment
ObjectTestModelCondition(object) bool
GetTerrainType(x,y) string
GetObjectId(object) number
GetObjectName(object) string
ObjectSetReference(object) -
GetObjectLuaRefZH(object) For compatibility with later sage game lua engine
GetObjectStringRefZH(object) For compatibility with later sage game lua engine
AddWaypoint(waypointname,x,y)
ObjectTestSelected(object) bool

Function for memory manipulation:

Function Return Values Example Comment
MemRead(AdressWithOffsetString,ValueTypeString) string MemRead(format("%X",tonumber(ObjectGetPointer(object),16)+4) .. "+3CC+0","int") Read any value from game memory
MemWrite(AdressWithOffsetString,ValueTypeString,NewValue) Write any value in game memory
ObjectGetPointer(object)
ThingTemplateGetPointer(object)
Clone this wiki locally