string into a function into obj:GetObjectValue(string) issue
EDIT:
It appears to work now, as you see in the output I called it with "headOBJ" instead of "ownerOBJ" and naturally that returned nil when I was messing with headless things ;)
---
I cant wrap my head around why the string I pass to my function is not recognized correctly when calling obj:GetObjectValue(name)
Code:
function The5Lib.GetPropertyObject(obj,name)
if (not IsMOSRotating(obj) ) then
print("ERROR: GetObjectValue requires a MOSRotating! " .. debug.getinfo(1).name .. debug.getinfo(1).source .. ":" .. debug.getinfo(1).currentline)
return nil
elseif IsMOSRotating(obj) then
--local mosr = ToMOSRotating(obj)
--print("mosr: ") print(mosr)
print("- - - - -")
print("name = " .. name)
local test = "ownerOBJ"
local prop1 = obj:GetObjectValue(test)
local prop2 = obj:GetObjectValue("ownerOBJ")
local prop3 = obj:GetObjectValue(name)
print("prop1: ") print(prop1)
print("prop2: ") print(prop2)
print("prop3: ") print(prop3)
else
return nil
end
end
is called like
Code:
self._owner = The5Lib.GetPropertyObject(self._properties,"ownerOBJ")
and produces
Code:
PRINT: - - - - -
PRINT: name = headOBJ
PRINT: prop1:
PRINT: Tayranian soldier, AHuman
PRINT: prop2:
PRINT: Tayranian soldier, AHuman
PRINT: prop3:
PRINT: nil
as you see, the third version, using the passed string, returns no value
And btw,
if you happen to have a way to print a string with a CC object table concatenated, let me know ;)
This does not seem to work
Code:
print("my object: " .. ccObjectTable)