-
-
Notifications
You must be signed in to change notification settings - Fork 7
CNC Generals Zero hour Lua scripting examples
MetaIdea edited this page Mar 14, 2024
·
5 revisions
for objectindex,object in globals() do
if strfind(objectindex, "ObjID") then
print(GetObjectName(object))
end
end
MyUnit = "test1"
ExecuteAction("CREATE_NAMED_ON_TEAM_AT_WAYPOINT", MyUnit, "AmericaVehicleDozer", "teamplayer0", "Player_1_Start")
print(GetObjectType(MyUnit))
x,y,z = ObjectGetPosition(MyUnit)
ObjectSetPosition(MyUnit,x,y,z+10)
local x,y,z
local ObjectList = {}
local ObjectType
local DuplicateOffset = 85
for objectIndex,object in globals() do
if strfind(objectIndex, "ObjID") then
ObjectType = GetObjectType(object)
if ObjectType == "SupplyDock" or ObjectType == "SupplyPile" or ObjectType == "SupplyWarehouse" then
tinsert(ObjectList, {object,ObjectType})
end
end
end
for i=1,getn(ObjectList),1 do
x,y,z = ObjectGetPosition(ObjectList[i][1])
ExecuteAction("UNIT_SPAWN_NAMED_LOCATION_ORIENTATION", GetUnitName(), ObjectList[i][2], NeutralTeam, {x+DuplicateOffset,y+DuplicateOffset,GetGroundHeight(x+DuplicateOffset,y+DuplicateOffset)}, ObjectGetRotation(ObjectList[i][1]))
end
function GetObjectBuildCost(object)
return MemRead(format("%X",tonumber(ObjectGetPointer(object),16)+4) .. "+3CC+0","int")
end
function MemReadGetObjectType(object)
return MemRead(format("%X",tonumber(ObjectGetPointer(object),16)+4) .. "+10+4+0","text")
end
function MemReadGetObjectHealth(object)
return MemRead(format("%X",tonumber(ObjectGetPointer(object),16)+372) .. "+8+0","float")
end
function GetObjectBuildCost(object)
return MemRead(format("%X",tonumber(ObjectGetPointer(object),16)+256) .. "+1C+0","int")
end
function GetPlayer(object)
local UnitName = GetObjectStringRef(object)
for i=1,getn(Players),1 do
if EvaluateCondition("NAMED_OWNED_BY_PLAYER", UnitName, Players[i]) then
return Players[i]
end
end
return "no player"
end