-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add component
upsert
function (#218)
feat: add insert_component script function
- Loading branch information
Showing
6 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...pting_lua/tests/data/insert_component/component_no_default_or_from_world_data_inserts.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local entity = world.spawn() | ||
local type = world.get_type_by_name('TestComponent') | ||
local entity_with_component = world._get_entity_with_test_component('TestComponent') | ||
local existing_component = world.get_component(entity_with_component, type) | ||
|
||
assert(world.has_component(entity, type) == false, 'Expected entity to not have component before adding, test invalid') | ||
world.insert_component(entity, type, existing_component) | ||
assert(world.has_component(entity, type) == true, 'Expected entity to have component after adding') |
8 changes: 8 additions & 0 deletions
8
...pting_lua/tests/data/insert_component/component_with_default_no_component_data_errors.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local entity = world.spawn() | ||
local _type = world.get_type_by_name('CompWithDefault') | ||
local entity_with_component = world._get_entity_with_test_component('CompWithDefault') | ||
local existing_component = world.get_component(entity_with_component, _type) | ||
|
||
assert_throws(function() | ||
world.insert_component(entity, _type, existing_component) | ||
end, "Missing type data ReflectComponent for type: .*CompWithDefault.*") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters