Cross-surface teleport for creative players#56
Merged
Conversation
Introduce a new dedicated access_teleport right end-to-end following the six-file new-right pattern: three levels (admin_only, current_surface_only, free) defaulting to current_surface_only, query functions, bulk-reset helper coverage, guarded storage initializer, admin-menu radio row, and localized captions/tooltips/messages in en, zh-CN, and zh-TW. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a Teleport tab to the cheats menu gated by the access_teleport right, cloning the surface target picker into teleport_menu_gui_data with friendly planet/platform/name labels. A one-shot teleport_to_surface apply cheat teleports a god/spectator player to a safe generated position on the chosen surface. compute_safe_position pre-generates destination terrain (chunk-unit radius) and finds a non-colliding spot (tile-unit radius) before teleporting. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extend teleport_to_surface to a three-way branch: same-surface selection repositions on the current surface, a player with a character is moved via clone -> teleport -> bind -> destroy original (preserving cheat_mode and reapplying character cheats), and god/spectator falls back to a direct cross-surface teleport. The clone is guarded against an invalid result so a failed clone can't leave the player charless. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add single_select_only to the teleport picker so the shared target-button click handler ignores ctrl/shift there (other pickers keep multi-select), and skip rendering the Select All button for single-select pickers so it can't be used to bypass the single-destination restriction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ff89889 to
874dfa3
Compare
fa9616f to
6aade3b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Artifacts | Task deep link | PR Walkthrough (alpha)
What problems was I solving
CreativeMod had no cross-surface teleport. The only teleport was the god-mode same-surface reposition, which explicitly notes "surface teleportation only works on player". A creative-mode player who wanted to build and test on Nauvis, another planet, or a space platform had to actually build a rocket or space platform to get there.
After this PR, a creative player can open a dedicated Teleport tab, pick any existing surface from a friendly-labeled list, and be teleported to a safe, generated position on it — instantly, with no rockets or platforms. It works in god/spectator mode, with a character (the body comes along with full inventory and equipment grid), and for the player's own surface (reposition to a fresh safe spot). The feature is gated by a new dedicated
access_teleportright and degrades gracefully on vanilla 2.x without Space Age.What user-facing changes did I ship
game.surfacewith friendly planet/platform labels (falling back to the raw surface name on vanilla) and a single "Teleport here" apply button — scripts/gui-menu-cheats.luaaccess_teleportright (admin-only / current-surface-only / free; default current-surface-only), configurable from the admin menu like every other right — scripts/rights.lua, scripts/gui-menu-admin.luaHow I implemented it
The work was built on the mod's existing data-driven cheat / picker / rights machinery, in four phases matching the four commits.
The new right (Phase 1)
access_teleport_levelenum (admin_only=0,current_surface_only=10,free=20), default, code, and two query functions:can_player_access_teleport_menu(visible unlessadmin_only) andcan_player_teleport_to_other_surfaces(cross-surface only whenfreeor admin). Extendedset_overall_admin_only(),set_overall_default(), and OR-ed the new menu intocan_player_access_cheats_menu.teleportentry inaccess_rights_gui_data; the generic click handler picks it up automatically.teleport_target_name_buttonmatch pattern used in Phase 2.The tab, picker, and teleport (Phase 2–3)
teleport_menu_gui_data, cloned fromsurface_cheats_menu_gui_data: same picker structure, friendlyplanet/platform/namecaptions,get_unverified_targets_functiongated by the new right, and a single apply-type cheat. Registered as ateleportentry incheats_menus_gui_data.compute_safe_position(base-game pvp.lua pattern: spawn position →request_to_generate_chunks→force_generate_chunk_requests→find_non_colliding_position, with the tile radius converted to a small chunk radius to avoid force-generating ~16k chunks). Theteleport_to_surfaceapply branches three ways: same surface → reposition; has character →move_player_with_character(clone the body to the destination, teleport, bind to the clone, destroy the original, restorecheat_mode, reapply character cheats); otherwise → plain cross-surfaceplayer.teleport.Single-select picker (Phase 4)
single_select_onlyflag on the teleport picker. In the shared click handler,control/shiftare forced off when the flag is set so a plain click selects exactly one destination; the Select All button is also skipped at render time for single-select pickers. Both changes are opt-in via the flag, so all other pickers keep their multi-select behavior.Deviations from the plan
No
*plan*.mdfile exists for this task — the work was driven by04-structure-outline-cross-surface-teleport.md, which the implementation followed phase by phase. All four phases are checked off in the outline. The deviations below are the decisions the outline itself recorded as "supersedes design sketch", plus one fix found during manual testing.Implemented as planned
access_teleportright end to end, the cloned Teleport tab + god-mode teleport, the character clone-move + same-surface reposition, and the single-select picker.surface.name.admin_onlyhides the tab,current_surface_onlyshows only the own surface,free/admin shows all.Deviations/surprises
apply_to_target_function(target, value, source_player), so the destination surface is the first arg and the player issource_player— not the shape the early design sketch assumed.Additions not in plan
single_select_onlyis set (other pickers keep it).Items planned but not implemented
How to verify it
Setup
Manual Testing
cheat_modestill on.admin_onlyhides the tab for a non-admin,current_surface_onlyshows only the own surface, andfreeshows all.Automated Tests
Description for the changelog
Added a Teleport tab to teleport creative-mode players to a safe position on any existing surface (god mode or character), gated by a new
access_teleportright.