Problems with changing metadata using csm...

Post Reply
User avatar
New member
Posts: 3
Joined: Mon Aug 31, 2020 16:00
Location: Russia

Problems with changing metadata using csm...


Is it possible to change itemstack and itemstackmetadata on the server from the modified minetest client? I want to rename items on the server using csm. I added the minetest.localplayer:set_wielded_item function to my client.

I added this to l_localplayer. h
static int l_set_wielded_item(lua_State *L);

And here's what I added in l_localplayer.cpp:

Code: Select all

int LuaLocalPlayer::l_set_wielded_item(lua_State *L)
	LocalPlayer *player = getobject(L, 1);
	IItemDefManager *idef;
	ItemStack item = read_item(L, 2, idef);
	InventoryList *mlist = player->inventory.getList("main");
	if (mlist) {
		mlist->changeItem(player->getWieldIndex(), item);
		return 1;
	return 0;

Code: Select all

luamethod(LuaLocalPlayer, set_wielded_item),
But changes to the item from the csm using set_wielded_item remain on the client. How do I send them to the server and apply them there?

User avatar
Posts: 844
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Problems with changing metadata using csm...

by orwell » Post

I think it would be best to have a server-side mod handle this. The client is not supposed to change item metadata on its own, there is by design no way to send metadata back to the server.
Rather communicate to a server mod (e.g. via chatcommand or modchannel) and set the metadata on the server side.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests