ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   GetPlacedFurnitureChildren return type (https://www.esoui.com/forums/showthread.php?t=8108)

Cardinal05 10/14/18 10:21 PM

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

sirinsidiator 10/15/18 05:29 AM

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.


All times are GMT -6. The time now is 09:38 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI