Page 1 of 1

[Oxyd] [0.17.4] Desync when defines.events.on_lua_shortcut handler tries to modify player.cursor_stack

Posted: Sun Mar 03, 2019 4:17 pm
by Atria
Description:
My mod is using new shortcuts to insert item into player's cursor_stack. But when event handler of defines.events.on_lua_shortcut tries to call player.clean_cursor() or player.cursor_stack.can_set_stack(...) or player.cursor_stack.set_stack(...) it causes a client to desync.

Code in question:

Code: Select all

function OnShortCut(event)
	local player = game.players[event.player_index]
	if player.clean_cursor() then
		local stack = player.cursor_stack
		if player.cursor_stack and stack.can_set_stack({ name = "steel-chest" }) then
			stack.set_stack({ name = "steel-chest" })
		end
	end
end

script.on_event(defines.events.on_lua_shortcut, OnShortCut)
Steps to reproduce:
-Install attached mod on server and client
-Start server and connect with client
-Open shortcut tool list
-Click on new shortcut (see attached screenshot)
-Enjoy desync

Attached mod, screenshot and desync report.

Re: [Oxyd] [0.17.4] Desync when defines.events.on_lua_shortcut handler tries to modify player.cursor_stack

Posted: Mon Mar 04, 2019 3:40 pm
by Oxyd
Thanks, fixed in 0.17.5.