The idea is to use the fact that Object.GetProperty and Object.SetProperty default to the "this" object if the first parameter is missing. I guessed that the globals me.i and me.u are used to accomplish this. so by changing these globals to match the one used in the internal database, you can then call the property function as if you where that other object. The only way i can think of to find the combination of i and u is to brute force the search space. This is crazy slow, but like I said, maybe someone can work something else out.
Code: Select all
function Create()
Object.SetProperty("DoLoop",true);
print() --get the debug screen
end
function Update( timePassed )
if Object.GetProperty("DoLoop") then
local id = Object.GetProperty("Id.i") --could use id = _G["me.i"]
local uid = Object.GetProperty("Id.u")
Game.DebugOut("My type is " .. Object.GetProperty("Type"))
Game.DebugOut("Starting Loop")
for i=0,150 do --150 the first 150 object
_G["me.i"] = i ..""
for u=0,2000 do --quit the game to get uid to reset to 0, u value can get very large very quickly
_G["me.u"] = u ..""
local t = Object.GetProperty("Type")
if t then
Game.DebugOut(i.." "..u.." : "..t)
if(t == "Tree") then
--setting "Type" didn't work for me
Object.SetProperty("SubType",2)
Object.SetProperty( "Age", 0)
end
end
end
end
--back to original values
_G["me.u"] = uid
_G["me.i"] = id
Object.SetProperty( "DoLoop", false);
end
end
Notes:
1) If you are testing this out then make sure you do it on a new map and a newish instance of PA. This should restart the uid index to 0, otherwise the search wont find the objects in the internal database.
2) you can not access the me.i (or me.u) global using the syntax me.i= xxx, this is becase lua thinks you are trying to access the table me with an index "i".
Code: Select all
me.i = XYZ
--equals
me["i"] = XYZ
see lua pil