mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Apply review.
This commit is contained in:
parent
1df282c635
commit
0b423bdb22
7 changed files with 19 additions and 21 deletions
|
@ -7849,12 +7849,12 @@ Global tables
|
||||||
* Values in this table may be modified directly.
|
* Values in this table may be modified directly.
|
||||||
Note: changes to initial properties will only affect entities spawned afterwards,
|
Note: changes to initial properties will only affect entities spawned afterwards,
|
||||||
as they are only read when spawning.
|
as they are only read when spawning.
|
||||||
* `core.object_refs`
|
|
||||||
* Map of active object references, indexed by active object id
|
|
||||||
* Obsolete: Use `core.objects_by_guid` instead.
|
|
||||||
GUIDs are strictly more useful than active object IDs.
|
|
||||||
* `core.objects_by_guid`
|
* `core.objects_by_guid`
|
||||||
* Map of active object references, indexed by object GUID
|
* Map of active object references, indexed by object GUID
|
||||||
|
* `core.object_refs`
|
||||||
|
* **Obsolete:** Use `core.objects_by_guid` instead.
|
||||||
|
GUIDs are strictly more useful than active object IDs.
|
||||||
|
* Map of active object references, indexed by active object id
|
||||||
* `core.luaentities`
|
* `core.luaentities`
|
||||||
* Map of Lua entities, indexed by active object id
|
* Map of Lua entities, indexed by active object id
|
||||||
* `core.registered_abms`
|
* `core.registered_abms`
|
||||||
|
@ -8555,10 +8555,10 @@ child will follow movement and rotation of that bone.
|
||||||
* `get_guid()`: returns a global unique identifier (a string)
|
* `get_guid()`: returns a global unique identifier (a string)
|
||||||
* For players, this is a player name.
|
* For players, this is a player name.
|
||||||
* For Lua entities, this is a uniquely generated string, guaranteed not to collide with player names.
|
* For Lua entities, this is a uniquely generated string, guaranteed not to collide with player names.
|
||||||
* Example: `@bGh3p2AbRE29Mb4biqX6OA`
|
* example: `@bGh3p2AbRE29Mb4biqX6OA`
|
||||||
* GUIDs only use printable ASCII characters.
|
* GUIDs only use printable ASCII characters.
|
||||||
* GUIDs are persisted internally between object reloads; their format is guaranteed not to change.
|
* GUIDs persist internally between object reloads; their format is guaranteed not to change.
|
||||||
Thus you can store GUIDs to identify objects persistently.
|
Thus you can use the GUID to identify an object in a particular world online nad offline.
|
||||||
|
|
||||||
|
|
||||||
#### Lua entity only (no-op for other objects)
|
#### Lua entity only (no-op for other objects)
|
||||||
|
|
|
@ -598,7 +598,7 @@ Since protocol version 37:
|
||||||
* `s32` pitch * 1000
|
* `s32` pitch * 1000
|
||||||
* `s32` roll * 1000
|
* `s32` roll * 1000
|
||||||
* if version2 >= 2:
|
* if version2 >= 2:
|
||||||
* u8[16] guid
|
* `u8[16]` guid
|
||||||
|
|
||||||
# Itemstring Format
|
# Itemstring Format
|
||||||
|
|
||||||
|
|
|
@ -257,19 +257,15 @@ end
|
||||||
unittests.register("test_item_drop", test_item_drop, {map=true})
|
unittests.register("test_item_drop", test_item_drop, {map=true})
|
||||||
|
|
||||||
local function test_entity_guid(_, pos)
|
local function test_entity_guid(_, pos)
|
||||||
log = {}
|
local obj0 = core.add_entity(pos, "unittests:dummy")
|
||||||
|
local obj1 = core.add_entity(pos, "unittests:dummy")
|
||||||
local obj0 = core.add_entity(pos, "unittests:callbacks")
|
|
||||||
check_log({"on_activate(0)"})
|
|
||||||
local obj1 = core.add_entity(pos, "unittests:callbacks")
|
|
||||||
check_log({"on_activate(0)"})
|
|
||||||
|
|
||||||
|
assert(obj0 ~= obj1)
|
||||||
|
assert(obj0:get_guid() ~= obj1:get_guid())
|
||||||
assert(core.objects_by_guid[obj0:get_guid()] == obj0)
|
assert(core.objects_by_guid[obj0:get_guid()] == obj0)
|
||||||
assert(core.objects_by_guid[obj1:get_guid()] == obj1)
|
assert(core.objects_by_guid[obj1:get_guid()] == obj1)
|
||||||
|
|
||||||
obj0:remove()
|
obj0:remove()
|
||||||
check_log({"on_deactivate(true)"})
|
|
||||||
obj1:remove()
|
obj1:remove()
|
||||||
check_log({"on_deactivate(true)"})
|
|
||||||
end
|
end
|
||||||
unittests.register("test_entity_guid", test_entity_guid, {map=true})
|
unittests.register("test_entity_guid", test_entity_guid, {map=true})
|
||||||
|
|
|
@ -209,6 +209,6 @@ unittests.register("test_player_hotbar_clamp", run_player_hotbar_clamp_tests, {p
|
||||||
-- Player get GUID
|
-- Player get GUID
|
||||||
--
|
--
|
||||||
local function test_player_guid_tests(player)
|
local function test_player_guid_tests(player)
|
||||||
assert(player:get_guid()==player:get_player_name())
|
assert(player:get_guid() == player:get_player_name())
|
||||||
end
|
end
|
||||||
unittests.register("test_player_guid", test_player_guid_tests, {player=true})
|
unittests.register("test_player_guid", test_player_guid_tests, {player=true})
|
||||||
|
|
|
@ -444,7 +444,9 @@ void ScriptApiBase::addObjectReference(ServerActiveObject *cobj)
|
||||||
objectstable = lua_gettop(L);
|
objectstable = lua_gettop(L);
|
||||||
|
|
||||||
// objects_by_guid[guid] = object
|
// objects_by_guid[guid] = object
|
||||||
lua_pushstring(L, cobj->getGUID().c_str());
|
auto guid = cobj->getGUID();
|
||||||
|
assert(!guid.empty());
|
||||||
|
lua_pushstring(L, guid.c_str());
|
||||||
lua_pushvalue(L, object);
|
lua_pushvalue(L, object);
|
||||||
lua_settable(L, objectstable);
|
lua_settable(L, objectstable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ void LuaEntitySAO::getStaticData(std::string *result) const
|
||||||
writeF1000(os, m_rotation.Y);
|
writeF1000(os, m_rotation.Y);
|
||||||
|
|
||||||
// version2. Increase this variable for new values
|
// version2. Increase this variable for new values
|
||||||
writeU8(os, 2); // PROTOCOL_VERSION >= 37
|
writeU8(os, 2);
|
||||||
|
|
||||||
writeF1000(os, m_rotation.X);
|
writeF1000(os, m_rotation.X);
|
||||||
writeF1000(os, m_rotation.Z);
|
writeF1000(os, m_rotation.Z);
|
||||||
|
|
|
@ -141,8 +141,8 @@ public:
|
||||||
virtual u16 getHP() const
|
virtual u16 getHP() const
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
/// Always returns the same unique string for the same object.
|
/// @brief Returns an unique ID for this object (persistent across unload, server restarts).
|
||||||
/// Because these strings are very short, copying them is not expensive.
|
/// @note Because these strings are very short, copying them is not expensive.
|
||||||
virtual std::string getGUID() = 0;
|
virtual std::string getGUID() = 0;
|
||||||
|
|
||||||
virtual void setArmorGroups(const ItemGroupList &armor_groups)
|
virtual void setArmorGroups(const ItemGroupList &armor_groups)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue