Page 1 of 1

[0.17.34] in events.on_player_setup_blueprint: player.cursor_stack.valid==true, but it's a lie!

Posted: Thu May 02, 2019 1:39 pm
by Qon
Step 1:

Code: Select all

/c 
script.on_event(defines.events.on_player_setup_blueprint, function(event) 
	local cs = game.players[event.player_index].cursor_stack 
	if cs.valid then 
		game.print(cs.name) 
	end 
end)
Step 2: Make a blueprint.
Step 3: Enjoy your crash.

What I expect: If I check if something is valid then it should be safe to use immediately after if I don't modify anything. I don't expect a crash when I write valid code :?

Re: [0.17.34] in events.on_player_setup_blueprint: player.cursor_stack.valid==true, but it's a lie!

Posted: Thu May 02, 2019 1:54 pm
by Bilka

Re: [0.17.34] in events.on_player_setup_blueprint: player.cursor_stack.valid==true, but it's a lie!

Posted: Thu May 02, 2019 2:17 pm
by Qon
Thanks. Is this 'valid_for_read' just for LuaItemStack or are there more classes where .valid is useless and needs to be randomly replaced with another property just to mess with modders? ;)