Data Realms Fan Forums

string into a function into obj:GetObjectValue(string) issue
Page 1 of 1

Author:  The5 [ Fri Aug 04, 2017 8:55 pm ]
Post subject:  string into a function into obj:GetObjectValue(string) issue

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)

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)
      return nil

is called like
   self._owner = The5Lib.GetPropertyObject(self._properties,"ownerOBJ")

and produces

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
print("my object: " .. ccObjectTable)

Author:  Bad Boy [ Thu Aug 10, 2017 4:37 am ]
Post subject:  Re: string into a function into obj:GetObjectValue(string) issue

I guess you've got whatever your issue was figured out now, that's good.

I don't remember if it'll work, but for concatenating a table to a string you could try doing print("my string "..tostring(table)). Might be you'll just have to iterate through everything in the table and build the string accordingly, or just check its size instead though; I haven't done any cc stuff in ages so I don't remember for the life of me if tostring'll work for this.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group