Quantcast GetPlacedFurnitureChildren return type - ESOUI
Thread Tools Display Modes
10/14/18, 10:21 PM   #1
Cardinal05
AddOn Author - Click to view addons
Join Date: Feb 2018
Posts: 32
GetPlacedFurnitureChildren return type

Hi and sorry to bother you guys, but [and please tell me if I am crazy] the return type for the function...

GetPlacedFurnitureChildren( id )

...may be a data type that isn't native to LUA (perhaps a C array that isn't cast for LUA? I am not sure how the game's host C++ executable passes data to/from the LUA interpreter)

The steps to reproduce this issue are:

1. Link multiple children to a parent item.
2. Use a statement similar to the following:

/script d( type( GetPlacedFurnitureChildren( parentItemId ) ) )

What I am seeing is "number", even though a statement such as...

/script d( GetPlacedFurnitureChildren( parentItemId ) )

...will output a 'list' of furniture Ids (the children). Interacting with this return value as if it were a table produces the standard "Operator # (or whatever) is not support for # number" error.

The strange part - and the reason why I think the return value may be cast incorrectly for LUA - is that the output is clearly a table, or at least an array-like structure.

The end result though is that I cannot index any id in the list beyond the first one as LUA refuses to allow it to be referenced as a table. I hope this information helps!

Thank you so much!
@Cardinal05
__________________
Geezus Take The Heal (@Cardinal05)
Adder of Ons : DecoTrack | Essential Housing Tools | Guild Alert | Lights of Meridia | Magic Carpet
  Reply With Quote
10/15/18, 05:29 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,269
I just tried it myself and from what I see, the function returns a variable number of id64 values.
The missing entry for ESOUIDocumentation would probably look like this:

* GetPlacedFurnitureChildren(*id64* _furnitureId_)
** _Uses variable returns..._
** _Returns:_ *id64:nilable* _childFurnitureId_

In order to iterate over them you could use one of the following approaches:
Lua Code:
  1. function test(...)
  2.     for i = 1, select("#", ...) do
  3.         local childId = select(i, ...)
  4.         d(Id64ToString(childId))
  5.     end
  6. end
  7. test(GetPlacedFurnitureChildren(HousingEditorGetSelectedFurnitureId()))
  8.  
  9. function test2()
  10.     local childIds = {GetPlacedFurnitureChildren(HousingEditorGetSelectedFurnitureId())}
  11.     for i = 1, #childIds do
  12.         local childId = childIds[i]
  13.         d(Id64ToString(childId))
  14.     end
  15. end
  16. test2()

P.s. Moved the thread since it doesn't belong in the wishlist.
__________________
Like what I do? Support me on Patreon!
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » GetPlacedFurnitureChildren return type

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off