What are the methods of object found by grp.find method?
Code:
123
obj = grp.find('1/1/1')
obj:write(3)
I've thinked that it has all grp methods but unfortunately not, e.g. there is no getvalue(). Maybe there is some description about its methods because when I log it I see only individual properties and no prototype's methods.
You can get object's meta-table (including meta-methods) like this:
Code:
1
log(getmetatable(obj))
Thanks. Yes, it is(it is something as screenshot). I've wanted stote the result of grp.find in a table and use this object later every 60s in Resident script and only use it via this methods. But while I want to use also updatetime then value update will be not enough. But I think you could add method like 'refresh' to not type again grp.find('1/1/1') but only e.g. obj.refresh()
You can get object's meta-table (including meta-methods) like this:
Code:
1
log(getmetatable(obj))
Thanks. Yes, it is(it is something as screenshot). I've wanted stote the result of grp.find in a table and use this object later every 60s in Resident script and only use it via this methods. But while I want to use also updatetime then value update will be not enough. But I think you could add method like 'refresh' to not type again grp.find('1/1/1') but only e.g. obj.refresh()
Hi buuuudzik
grp.find('alias') already return a table, why you cannot just write a function to perform some tests and make changes in this table ?
I am not understanding what you need obj.refresh() as refresh also means update.
06.11.2018, 14:41 (This post was last modified: 06.11.2018, 14:55 by buuuudzik.)
This is an example:
Code:
12345678910111213141516171819202122232425262728
-- WITHOUT .refresh() is:ifnotobjectsthenobjects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
fori=1, #objects, 1doobjects[i] = grp.find(objects[i]) endelsefori=1, #objects, 1doobjects[i] = grp.find(objects[i].address) endend-- DO SOME JOBfori=1, #objects, 1dolog(objects[i].value) endos.sleep(300)
-- WITH .refresh() could be:ifnotobjectsthenobjects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
fori=1, #objects, 1doobjects[i] = grp.find(objects[i]) endelsefori=1, #objects, 1doobjects[i]:refresh() end-- HERE IS THE DIFFERENCEend-- DO SOME JOBfori=1, #objects, 1dolog(objects[i].value) endos.sleep(300)
I know how to deal with this situation but I would like such method:
Code:
1
object:refresh()
instead of:
Code:
1
object = grp.find(object.address)
The name is not a case, this was only a suggestion.
And I don't want add this method individually to every object but only to its prototype. And maybe not by me but by manufacturer to use it in further coding without requiring some package
(06.11.2018, 14:41)buuuudzik Wrote: This is an example:
Code:
12345678910111213141516171819202122232425262728
-- WITHOUT .refresh() is:ifnotobjectsthenobjects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
fori=1, #objects, 1doobjects[i] = grp.find(objects[i]) endelsefori=1, #objects, 1doobjects[i] = grp.find(objects[i].address) endend-- DO SOME JOBfori=1, #objects, 1dolog(objects[i].value) endos.sleep(300)
-- WITH .refresh() could be:ifnotobjectsthenobjects = {'1/1/1', '1/1/2', '1/1/3', '1/1/4'}
fori=1, #objects, 1doobjects[i] = grp.find(objects[i]) endelsefori=1, #objects, 1doobjects[i]:refresh() end-- HERE IS THE DIFFERENCEend-- DO SOME JOBfori=1, #objects, 1dolog(objects[i].value) endos.sleep(300)
I know how to deal with this situation but I would like such method:
Code:
1
object:refresh()
instead of:
Code:
1
object = grp.find(object.address)
The name is not a case, this was only a suggestion.
And I don't want add this method individually to every object but only to its prototype. And maybe not by me but by manufacturer to use it in further coding without requiring some package