Unit Parameter for LUA Scripts


#1

Hi, folks

I’d like to know if there’s any way to see the parameter UNIT from a resource using a object call in LUA scripting, like “Dataport.alias” to look at the Dataport Alias, for example.

Any help would be great, thanks in advance!


#2

Hi Tiago,

There sure is a way to see the units value of a dataport inside a One Platform lua script. Using the manage table you can the information about a particular resource using that table’s info method. If a dataport has a unit value, it will be stored inside that resource’s meta field.

See this lua code that uses the manage table to get an RID’s meta field:

local success, message = manage.info("<YOUR_RID>", {"description"})

debug(tostring(success))
debug(message.description.meta)

FYI meta information is stored as a string so you may have to decode it.

Let me know if you have quesitons about this,
-Martin


#3

Thank you very much, Martin!

Everything worked fine here, you helped me a lot!

-Tiago