View unanswered posts | View active topics It is currently Sun Nov 29, 2020 5:09 am

Reply to topic  [ 2 posts ] 
 string into a function into obj:GetObjectValue(string) issue 
Author Message
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post 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)

Fri Aug 04, 2017 8:55 pm
Profile WWW

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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.

Thu Aug 10, 2017 4:37 am
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.014s | 13 Queries | GZIP : Off ]