Jump to content

LauNet - sending inventory items


Dr_Cox1911

Recommended Posts

Greetings,

 

kinda stuck with LuaNet and really need your help guys.

I want to transfer an inventoryitem (basically a table) with LuaNet, but for some reason it doesn´t send the table as payload, instead I receive an empty table transmitted.

 

So what I want to do in a nutshell:

local player = getPlayer();
local inv = player:getInventory();

module.sendPlayer(getPlayer(),"senditem", inv);

(Maybe @turbotutone might know what´s going on there)

Edited by Dr_Cox1911
edited sendPlayer to reflect the proper parameter passing, specified title
Link to comment
Share on other sites

Seems like it doesn´t support sending the converted java object that reflects the inventory item.

 

Currently working on a temporary solution by not sending the actual item, but instead all the info regarding that item. Think this is somehow possible with ModData, just need to find a way to populate the ModData of the item object with all the stats like condition, cooked, ...

 

Sloppy way that I don´t want to do:

Checking with "instanceof" which type of item it is and then getting all the info with the "get"-functions and populate the ModData. Downside to this approach: Whenever an item type like food gets a new info I need to alter my mod.

Edited by Dr_Cox1911
Link to comment
Share on other sites

Yes, finding out that ModData isn't automagically populated with variables within the class was pretty disappointing to find out.

 

Problem is, reflection is off the table. If those variables aren't accessible via public functions, you won't be able to check them.  (e.g. item:getCooked() returns boolean, thus t["isCooked"]=true).

Link to comment
Share on other sites

18 minutes ago, Butter Bot said:

Yes, finding out that ModData isn't automagically populated with variables within the class was pretty disappointing to find out.

Just curious, but is there a technical reason for this?

There is a field and parameter called "DefaultModData", but this is also empty.

 

Will sleep a night on this matter, but I think getting all the variables that have a get-function seems to be the only way :-(

Haven´t really checked if all necessary variables have those.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...