diff --git a/.docs/package.json b/.docs/package.json index e21ccc0..48c7649 100644 --- a/.docs/package.json +++ b/.docs/package.json @@ -1,6 +1,6 @@ { "name": "worldeditadditions", - "version": "1.14.1", + "version": "1.14.5", "description": "Documentation website for WorldEditAdditions", "main": "index.js", "private": true, diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..fd8760a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,26 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +What's the bug? Be clear and concise in our explanation. Don't forget to include any context, error messages, logs, and screenshots required to understand the issue if applicable. + +**Reproduction steps:** +Steps to reproduce the behaviour: +1. Go to '...' +2. Click on '....' +3. Enter this command to '....' +4. See error + +**System information (please complete the following information):** + - **Operating system and version:** [e.g. iOS] + - **Minetest version:** [e.g. 5.8.0] +- **WorldEdit version:** +- **WorldEditAdditions version:** + +Please add any other additional specific system information here too if you think it would help. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..e141780 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +## Problem +A clear and concise description of what the problem you want to solve is. e.g. I'm always frustrated when [...] + +## Solution +Describe clearly the solution you'd like. + +## Alternatives +A clear and concise description of any alternative solutions or features you've considered, and how they relate to your proposed feature. + +## Additional context +Add any other context or screenshots about the feature request here. + +Don't forget to remove replace descriptions, but keep the headers. diff --git a/CHANGELOG.md b/CHANGELOG.md index 32594e3..c6015fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ It's about time I started a changelog! This will serve from now on as the main c Note to self: See the bottom of this file for the release template text. + +## v1.14.5: The multipoint update, hotfix 5 (1st August 2023) +- Fix a bug where creative players in survival couldn't punch out position markers +- Added `//listentities`, which lists all currently loaded `ObjectRef`s. This is intended for debugging mods - thanks to @Zughy in #103 + + +## v1.14.4: The multipoint update, hotfix 4 (31st July 2023) +- When any segment of the marker wall is punched, unmark the entire wall + + +## v1.14.3: The multipoint update, hotfix 3 (18th July 2023) +- Fix regions not remembering their state and being unresettable + + +## v1.14.2: The multipoint update, hotfix 2 (15th July 2023) +- Fix crash in `//subdivide`, again due to the new position system + + ## v1.14.1: The multipoint update, hotfix 1 (12th July 2023) - Fix issue #100, which caused a crash as `//pos1` and `//pos2` allowed non-integer positions to be set diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index d522630..95fd7e2 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -1349,6 +1349,17 @@ Here are some more examples: ``` +### `//listentities` +Lists all currently loaded ObjectRefs. Displays their IDs, Names (if possible), and possitions. + +This command is intended for development and modding. You will not normally need to use this command using WorldEditAdditions. + +`//listentities` takes no arguments. + +``` +//listentities +``` + ## Extras START player_name", player_name, "pos1", pos1, "pos2", pos2, "side", side, "SPAWN", pos_centre, "last_reset", last_reset) - entity:get_luaentity().player_name = player_name + -- entity:get_luaentity().player_name = player_name - single_setup(entity, pos2 - pos1, side) + -- single_setup(entity, pos2 - pos1, side) return entity end @@ -438,7 +471,7 @@ local function delete(entitylist) entity:remove() end - last_reset = tostring(wea_c.get_ms_time()) + last_reset = make_id() -- print("DEBUG:marker_wall delete --> LAST_RESET is now", last_reset, "type", type(last_reset)) anchor:emit("delete", { @@ -450,7 +483,8 @@ end anchor = EventEmitter.new({ create = create_wall, - delete = delete + delete = delete, + __single_setup = single_setup }) return anchor \ No newline at end of file diff --git a/worldeditadditions_core/core/pos.lua b/worldeditadditions_core/core/pos.lua index 9fe7abe..6b968a2 100644 --- a/worldeditadditions_core/core/pos.lua +++ b/worldeditadditions_core/core/pos.lua @@ -33,7 +33,7 @@ local anchor = nil --- It is requested that all position/region marker UI elements be hidden for the given player. -- @event unmark --- @format { player_name: string } +-- @format { player_name: string, markers: bool, walls: bool } --- It is requested that all position/region marker UI elements be shown once more for the given player. -- @event mark @@ -268,15 +268,24 @@ end --- Hides the visual markers for the given player's positions and defined region, but does not clear the points. -- @param player_name string The name of the player to operate on. -local function unmark(player_name) +-- @param markers=true bool Whether to hide positional markers. +-- @param walls=true bool Whether to hide the marker walls. +-- @returns void +local function unmark(player_name, markers, walls) + if markers == nil then markers = true end + if walls == nil then walls = true end + anchor:emit("unmark", { - player_name = player_name + player_name = player_name, + markers = markers, + walls = walls }) end --- Shows the visual markers for the given player's positions and defined region once more. -- Often used some time after calling worldeditadditions_core.pos.unmark(). -- @param player_name string The name of the player to operate on. +-- @returns void local function mark(player_name) anchor:emit("mark", { player_name = player_name diff --git a/worldeditadditions_core/core/pos_marker_manage.lua b/worldeditadditions_core/core/pos_marker_manage.lua index 8272292..8668eca 100644 --- a/worldeditadditions_core/core/pos_marker_manage.lua +++ b/worldeditadditions_core/core/pos_marker_manage.lua @@ -92,8 +92,9 @@ end) wea_c.pos:addEventListener("unmark", function(event) ensure_player(event.player_name) - do_delete_all(event.player_name) - + if event.markers then + do_delete_all(event.player_name) + end -- Note that this function is NOT WorldEdit compatible, because it is only called through our override of WorldEdit's `//unmark`, and WorldEdit doesn't have an API function to call to unmark and everything is complicated. end) @@ -109,4 +110,12 @@ wea_c.pos:addEventListener("mark", function(event) pos = pos }) end -end) \ No newline at end of file +end) + + +wea_c.entities.pos_marker:addEventListener("update_entity", function(event) + wea_c.entities.pos_marker.delete( + position_entities[event.player_name][event.i] + ) + position_entities[event.player_name][event.i] = event.entity +end) diff --git a/worldeditadditions_core/core/pos_marker_wall_manage.lua b/worldeditadditions_core/core/pos_marker_wall_manage.lua index 4e6c5da..996e499 100644 --- a/worldeditadditions_core/core/pos_marker_wall_manage.lua +++ b/worldeditadditions_core/core/pos_marker_wall_manage.lua @@ -53,6 +53,26 @@ local function do_update(event) end +local function garbage_collect(player_name) + if not wall_entity_lists[player_name] then return end -- Nothing to do + + for i, entity in ipairs(wall_entity_lists[player_name]) do + if not entity:get_pos() then + table.remove(wall_entity_lists[player_name], i) + end + end +end + +local function update_entity(event) + print("DEBUG:pos_marker_wall_manage UPDATE_ENTITY event", weac.inspect(event)) + garbage_collect(event.player_name) + + ensure_player(event.player_name) + table.insert( + wall_entity_lists[event.player_name], + event.entity + ) +end local function needs_update(event) if event.i > 2 then @@ -65,11 +85,16 @@ local function handle_event(event) if needs_update(event) then do_update(event) end end +local function handle_unmark(event) + if event.walls then do_delete(event) end +end weac.pos:addEventListener("set", handle_event) weac.pos:addEventListener("pop", handle_event) weac.pos:addEventListener("push", handle_event) weac.pos:addEventListener("clear", do_delete) -weac.pos:addEventListener("unmark", do_delete) +weac.pos:addEventListener("unmark", handle_unmark) weac.pos:addEventListener("mark", do_update) + +weac.entities.pos_marker_wall:addEventListener("update_entity", update_entity) \ No newline at end of file diff --git a/worldeditadditions_core/init.lua b/worldeditadditions_core/init.lua index 91108e8..a597f31 100644 --- a/worldeditadditions_core/init.lua +++ b/worldeditadditions_core/init.lua @@ -1,6 +1,6 @@ --- WorldEditAdditions-Core -- @namespace worldeditadditions_core --- @release 1.14.1 +-- @release 1.14.5 -- @copyright 2021 Starbeamrainbowlabs and VorTechnix -- @license Mozilla Public License, 2.0 -- @author Starbeamrainbowlabs and VorTechnix diff --git a/worldeditadditions_core/utils/EventEmitter.lua b/worldeditadditions_core/utils/EventEmitter.lua index 4632606..adbde5a 100644 --- a/worldeditadditions_core/utils/EventEmitter.lua +++ b/worldeditadditions_core/utils/EventEmitter.lua @@ -58,8 +58,12 @@ end -- @param event_name string The name of the event to emit. -- @param args table|any The argument(s) to pass to listener functions. It is strongly advised you pass a table here. function EventEmitter.emit(this, event_name, args) + if this.debug then + listeners = 0 + if this.events[event_name] ~= nil then listeners = #this.events[event_name] end + print("DEBUG:EventEmitter emit", event_name, "listeners", listeners, "args", wea_c.inspect(args)) + end if this.events[event_name] == nil then return end - if this.debug then print("DEBUG:EventEmitter emit", event_name, "args", wea_c.inspect(args)) end for index,next_func in ipairs(this.events[event_name]) do next_func(args)