mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-10-26 21:35:28 +01:00 
			
		
		
		
	Set placer to nil instead of a non-functional one in item_OnPlace (#6449)
* Set placer to nil instead of a non-functional one This requires nil checks in core.rotate_node and core.rotate_and_place.
This commit is contained in:
		| @@ -69,7 +69,12 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item, | ||||
| 
 | ||||
| 	// Call function
 | ||||
| 	LuaItemStack::create(L, item); | ||||
| 	objectrefGetOrCreate(L, placer); | ||||
| 
 | ||||
| 	if (!placer) | ||||
| 		lua_pushnil(L); | ||||
| 	else | ||||
| 		objectrefGetOrCreate(L, placer); | ||||
| 
 | ||||
| 	pushPointedThing(pointed); | ||||
| 	PCALL_RES(lua_pcall(L, 3, 1, error_handler)); | ||||
| 	if (!lua_isnil(L, -1)) { | ||||
|   | ||||
| @@ -291,9 +291,8 @@ int ModApiEnvMod::l_place_node(lua_State *L) | ||||
| 	pointed.type = POINTEDTHING_NODE; | ||||
| 	pointed.node_abovesurface = pos; | ||||
| 	pointed.node_undersurface = pos + v3s16(0,-1,0); | ||||
| 	// Place it with a NULL placer (appears in Lua as a non-functional
 | ||||
| 	// ObjectRef)
 | ||||
| 	bool success = scriptIfaceItem->item_OnPlace(item, NULL, pointed); | ||||
| 	// Place it with a NULL placer (appears in Lua as nil)
 | ||||
| 	bool success = scriptIfaceItem->item_OnPlace(item, nullptr, pointed); | ||||
| 	lua_pushboolean(L, success); | ||||
| 	return 1; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user