mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-10-31 15:35:21 +01:00 
			
		
		
		
	Add persistent unique identifiers for objects (#14135)
This commit is contained in:
		| @@ -255,3 +255,17 @@ local function test_item_drop(_, pos) | ||||
| 	assert(itemstack_ret:equals(itemstack_src)) | ||||
| end | ||||
| unittests.register("test_item_drop", test_item_drop, {map=true}) | ||||
|  | ||||
| local function test_entity_guid(_, pos) | ||||
| 	local obj0 = core.add_entity(pos, "unittests:dummy") | ||||
| 	local obj1 = core.add_entity(pos, "unittests:dummy") | ||||
|  | ||||
| 	assert(obj0 ~= obj1) | ||||
| 	assert(obj0:get_guid() ~= obj1:get_guid()) | ||||
| 	assert(core.objects_by_guid[obj0:get_guid()] == obj0) | ||||
| 	assert(core.objects_by_guid[obj1:get_guid()] == obj1) | ||||
|  | ||||
| 	obj0:remove() | ||||
| 	obj1:remove() | ||||
| end | ||||
| unittests.register("test_entity_guid", test_entity_guid, {map=true}) | ||||
|   | ||||
| @@ -204,3 +204,12 @@ local function run_player_hotbar_clamp_tests(player) | ||||
| 	player:hud_set_hotbar_itemcount(old_bar_size) | ||||
| end | ||||
| unittests.register("test_player_hotbar_clamp", run_player_hotbar_clamp_tests, {player=true}) | ||||
|  | ||||
| -- | ||||
| -- Player GUID | ||||
| -- | ||||
| local function test_player_guid(player) | ||||
| 	assert(player:get_guid() == player:get_player_name()) | ||||
| 	assert(core.objects_by_guid[player:get_guid()] == player) | ||||
| end | ||||
| unittests.register("test_player_guid", test_player_guid, {player=true}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user