Jump to content

LoganDark

Members
  • Posts

    2
  • Joined

LoganDark's Achievements

0

Reputation

  1. https://www.avorion.net/forum/index.php/topic,6108.0.html Summary: Allow invokeClient/ServerFunction to transfer Inventory, allow InventorySelection:fill() to accept an Inventory as an argument
  2. I'm making a mod that currently lets admins view the inventory of other players (there are future plans). Right now I have to send each item, amount and index individually to the client, which will then manually construct an InventorySelectionItem for each one and add it to the InventorySelection in the window. Boooring, slow, network intensive, and glitchy. The InventorySelection doesn't like items being added manually, and things like the built-in search bar are glitchy and broken. add() somehow misses something that fill() does. The reason I can't use a faction index is because the client doesn't know what's in the inventory of other factions. Passing a faction index gives me no control over what data the InventorySelection retreives and, in this case it's just blank, unless it's your own ship, in which case it actually works way better than the hacky method does. So I would like to feed data to the InventorySelection the same way fill does, but using my own Inventory object, so that it works correctly (including the search bar and dropdowns). For that I need the Inventory in the first place, so the server needs to be able to send that. So, really, my two requests are: - Allow the server to send an Inventory object to the client (just make Inventory serializable) - Allow me to use inventorySelection:fill(Inventory) in addition to inventoryselection:Fill(factionIndex) That way, I'll be happy because I'm feeding data to the InventorySelection in a sane way, and getting the data in a sane way as well. If these features get added, then rather than doing this (my current solution, works but some functionality of the InventorySelection breaks, like the search bar): function LDinv.onShowWindow() LDinv.duplicateInv:clear() -- LDinv.duplicateInv:fill(LDinv.entity.factionIndex) invokeServerFunction('sendInventory') end function LDinv.sendInventory() local inv = Faction(LDinv.entity.factionIndex):getInventory() for i = 0, inv.occupiedSlots - 1 do LDinv.sendItem(inv:find(i), i, inv:amount(i)) end end callable(LDinv, 'sendInventory') function LDinv.sendItem(item, index, amount) invokeClientFunction(LDinv.player, 'updateInventory', item, index, amount) end function LDinv.updateInventory(item, index, amount) print('inventory update: ' .. tostring(item) .. ' x ' .. tostring(amount) .. ' @ ' .. index) local isi = InventorySelectionItem() if item then isi.item = item end isi.amount = amount LDinv.duplicateInv:add(isi, index) end I'd be able to do this (which ideally would be practically equivalent to fill(factionIndex), just getting the inventory from the server): function LDinv.onShowWindow() LDinv.duplicateInv:clear() -- LDinv.duplicateInv:fill(LDinv.entity.factionIndex) invokeServerFunction('sendInventory') end function LDinv.sendInventory() invokeClientFunction(LDinv.player, 'updateInventory', Faction(LDinv.entity.factionIndex):getInventory()) end callable(LDinv, 'sendInventory') function LDinv.updateInventory(inventory) LDinv.duplicateInv:clear() LDinv.duplicateInv:fill(inventory) end I've discussed this with many other people like Bubbet, KaneNOD, Acuddle and Shrooblord and I've come to the conclusion that this is currently impossible to do. I'd appreciate if these features could be added to the API. I feel like they'd be a welcome addition, and the lack of such features definitely makes it feel incomplete to me. Thanks for your consideration.
×
×
  • Create New...