From 8c4a606384c1c2ce59cc84fc809cd4d2cd78f85c Mon Sep 17 00:00:00 2001 From: Gboster-0 <82319946+Gboster-0@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:32:34 +0100 Subject: [PATCH 1/4] daedalusdock #675 port --- code/__DEFINES/~monkestation/asteroids.dm | 9 ++++ .../asteroids/asteroid_generation.dm | 6 +-- .../asteroids/asteroid_magnet.dm | 44 ++++++++++++++----- .../asteroids/asteroid_template.dm | 6 ++- .../asteroids/cartesian_plane.dm | 4 +- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/~monkestation/asteroids.dm b/code/__DEFINES/~monkestation/asteroids.dm index 1e8792bbd61f..f9c081449d09 100644 --- a/code/__DEFINES/~monkestation/asteroids.dm +++ b/code/__DEFINES/~monkestation/asteroids.dm @@ -1,6 +1,8 @@ /// Used in asteroid composition lists to indicate a skip #define SKIP "skip" +#define islevelbaseturf(A) istype(A, SSmapping.level_trait(A.z, ZTRAIT_BASETURF) || /turf/open/space) + // Mining template rarities #define MINING_NO_RANDOM_SPAWN -1 #define MINING_COMMON 1 @@ -14,3 +16,10 @@ stoplag(); \ SSatoms.map_loader_begin(REF(template)); \ } + +// error codes for the asteroid magnet +#define MAGNET_ERROR_KEY_BUSY 1 +#define MAGNET_ERROR_KEY_USED_COORD 2 +#define MAGNET_ERROR_KEY_COOLDOWN 3 +#define MAGNET_ERROR_KEY_MOB 4 +#define MAGNET_ERROR_KEY_NO_COORD 5 diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_generation.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_generation.dm index d1769261d410..0ea3c8152080 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_generation.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_generation.dm @@ -75,7 +75,7 @@ /// Cleanup our currently loaded mining template /proc/CleanupAsteroidMagnet(turf/center, size) - var/list/turfs_to_destroy = ReserveTurfsForAsteroidGeneration(center, size, space_only = FALSE) + var/list/turfs_to_destroy = ReserveTurfsForAsteroidGeneration(center, size, baseturf_only = FALSE) for(var/turf/T as anything in turfs_to_destroy) CHECK_TICK @@ -88,12 +88,12 @@ T.ChangeTurf(/turf/baseturf_bottom) /// Sanitizes a block of turfs to prevent writing over undesired locations -/proc/ReserveTurfsForAsteroidGeneration(turf/center, size, space_only = TRUE) +/proc/ReserveTurfsForAsteroidGeneration(turf/center, size, baseturf_only = TRUE) . = list() var/list/turfs = RANGE_TURFS(size, center) for(var/turf/T as anything in turfs) - if(space_only && !isspaceturf(T)) + if(baseturf_only && !islevelbaseturf(T)) continue if(!(istype(T.loc, /area/station/cargo/mining/asteroid_magnet))) continue diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm index dfc3e33c5f42..50e7b0bf3fc0 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm @@ -3,6 +3,7 @@ /obj/machinery/asteroid_magnet name = "asteroid magnet computer" + desc = "Control panel for the asteroid magnet." icon_state = "blackbox" resistance_flags = INDESTRUCTIBLE use_power = NO_POWER_USE @@ -32,6 +33,11 @@ /// Status of the user interface var/status = STATUS_OKAY + /// Boolean to keep track of state and protect against double summoning + var/summon_in_progress = FALSE + + /// The cooldown between uses. + COOLDOWN_DECLARE(summon_cd) /obj/machinery/asteroid_magnet/Initialize(mapload) . = ..() @@ -86,7 +92,7 @@ return if(href_list["summon_selected"]) - summon_sequence() + summon_sequence(selected_template) return /obj/machinery/asteroid_magnet/ui_interact(mob/user, datum/tgui/ui) @@ -211,7 +217,7 @@ bg_color = "#e67300 !important" content += {"
- [template.name] ([template.x],[template.y]) + [template.name] ([template.x], [template.y])
"} @@ -263,24 +269,35 @@ /// Test to see if we should clear the magnet area. /// Returns FALSE if it can clear, returns a string error message if it can't. -/obj/machinery/asteroid_magnet/proc/check_for_magnet_errors() +/obj/machinery/asteroid_magnet/proc/check_for_magnet_errors(datum/mining_template/template) . = FALSE - if(isnull(selected_template)) - return "ERROR N1" + if(summon_in_progress) + return "ERROR: ASTEROID ALREADY BEING SUMMONED" + + if(!COOLDOWN_FINISHED(src, summon_cd)) + return "ERROR: MAGNET COOLING DOWN" + + if(isnull(template)) + return "ERROR: ASTEROID NOT DETECTED" + + if(template.summoned) + return "ERROR: ASTEROID ALREADY SUMMONED" for(var/mob/M as mob in range(area_size + 1, center_turf)) if(isliving(M)) - return "ERROR C3" + return "ERROR: HEAT SIGNATURES DETECTED ON THE ASTEROID" /// Performs a full summoning sequence, including putting up boundaries, clearing out the area, and bringing in the new asteroid. /obj/machinery/asteroid_magnet/proc/summon_sequence(datum/mining_template/template) - var/magnet_error = check_for_magnet_errors() + var/magnet_error = check_for_magnet_errors(template) if(magnet_error) status = magnet_error updateUsrDialog() return var/area/station/cargo/mining/asteroid_magnet/A = get_area(center_turf) + + summon_in_progress = TRUE A.area_flags |= NOTELEPORT // We dont want people getting nuked during the generation sequence status = "Summoning[ellipsis()]" available_templates -= template @@ -289,21 +306,24 @@ var/time = world.timeofday var/list/forcefields = PlaceForcefield() CleanupTemplate() - PlaceTemplate(selected_template) + PlaceTemplate(template) /// This process should take ATLEAST 20 seconds time = (world.timeofday + 20 SECONDS) - time if(time > 0) - addtimer(CALLBACK(src, PROC_REF(_FinishSummonSequence), forcefields), time) + addtimer(CALLBACK(src, PROC_REF(_FinishSummonSequence), template, forcefields), time) else - _FinishSummonSequence(forcefields) + _FinishSummonSequence(template, forcefields) return -/obj/machinery/asteroid_magnet/proc/_FinishSummonSequence(list/forcefields) +/obj/machinery/asteroid_magnet/proc/_FinishSummonSequence(datum/mining_template/template, list/forcefields) QDEL_LIST(forcefields) var/area/station/cargo/mining/asteroid_magnet/A = get_area(center_turf) A.area_flags &= ~NOTELEPORT // Annnnd done + summon_in_progress = FALSE + template.summoned = TRUE + COOLDOWN_START(src, summon_cd, 1 MINUTE) status = STATUS_OKAY updateUsrDialog() @@ -326,7 +346,7 @@ /obj/machinery/asteroid_magnet/proc/CleanupTemplate() PRIVATE_PROC(TRUE) - var/list/turfs_to_destroy = ReserveTurfsForAsteroidGeneration(center_turf, area_size, space_only = FALSE) + var/list/turfs_to_destroy = ReserveTurfsForAsteroidGeneration(center_turf, area_size, baseturf_only = FALSE) for(var/turf/T as anything in turfs_to_destroy) CHECK_TICK diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_template.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_template.dm index 3b184047d5d5..2edf807938a5 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_template.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_template.dm @@ -11,9 +11,11 @@ // Asteroid Map location var/x var/y - var/found = FALSE - + /// Has this template been located by players? + var/found = FALSE + /// Has this template been summoned? + var/summoned = FALSE /datum/mining_template/New(center, max_size) . = ..() diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/cartesian_plane.dm b/monkestation/code/modules/art_sci_overrides/asteroids/cartesian_plane.dm index 56030039bb4e..e34c47298175 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/cartesian_plane.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/cartesian_plane.dm @@ -1,9 +1,9 @@ /* * For a new plane of (x,x'),(y,y') : offset_x,offset_y,x_size,y_size * - * //Sign changes must account for 0-crossing + * // Sign changes must account for 0-crossing * (-100,100),(0,0) : 101,1,201,1 - * //Otherwise, it does not + * // Otherwise, it does not * (-100,-50),(0,0) : 101,1,50,1 * (50,100) , (0,0) : -49,1,50,1 */ From 35109b8c494ba6c57827b55f7b67814935f477f1 Mon Sep 17 00:00:00 2001 From: Gboster-0 <82319946+Gboster-0@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:54:14 +0100 Subject: [PATCH 2/4] my first TGUI, and its amazing <3 --- _maps/_basemap.dm | 2 +- .../asteroids/asteroid_magnet.dm | 317 ++++++++---------- .../tgui/interfaces/AsteroidMagnet.js | 115 +++++++ 3 files changed, 250 insertions(+), 184 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/AsteroidMagnet.js diff --git a/_maps/_basemap.dm b/_maps/_basemap.dm index 0ca8b906560e..60ffa1b88918 100644 --- a/_maps/_basemap.dm +++ b/_maps/_basemap.dm @@ -1,4 +1,4 @@ -//area#define LOWMEMORYMODE //uncomment this to load centcom and runtime station and thats it. +//#define LOWMEMORYMODE //uncomment this to load centcom and runtime station and thats it. #include "map_files\generic\CentCom.dmm" diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm index 50e7b0bf3fc0..6e57c5661999 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm @@ -29,12 +29,15 @@ var/coords_x = 0 var/coords_y = 0 - var/ping_result = "N/A
...
" + var/ping_result = "Awaiting first ping" /// Status of the user interface var/status = STATUS_OKAY /// Boolean to keep track of state and protect against double summoning var/summon_in_progress = FALSE + /// Are we currently automatically pinging the target? + var/Auto_pinging = FALSE + /// The cooldown between uses. COOLDOWN_DECLARE(summon_cd) @@ -57,186 +60,6 @@ GenerateMap() -/obj/machinery/asteroid_magnet/Topic(href, href_list) - . = ..() - if(.) - return - - var/list/map_offsets = map.return_offsets() - var/list/map_bounds = map.return_bounds() - var/value = text2num(href_list["x"] || href_list["y"]) - if(!isnull(value)) // round(null) = 0 - value = round(value, 1) - if("x" in href_list) - coords_x = WRAP(coords_x + map_offsets[1] + value, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - updateUsrDialog() - - else if("y" in href_list) - coords_y = WRAP(coords_y + map_offsets[2] + value, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - updateUsrDialog() - return - - if(href_list["ping"]) - ping(coords_x, coords_y) - updateUsrDialog() - return - - if(href_list["select"]) - var/datum/mining_template/T = locate(href_list["select"]) in available_templates - if(!T) - return - selected_template = T - updateUsrDialog() - return - - if(href_list["summon_selected"]) - summon_sequence(selected_template) - return - -/obj/machinery/asteroid_magnet/ui_interact(mob/user, datum/tgui/ui) - var/content = list() - - content += {" -
-
- - Magnet Controls - - "} - - // X selector - content += {" -
- - X-Axis - -
-
[button_element(src, "-100", "x=-100")]
-
[button_element(src, "-10", "x=-10")]
-
[button_element(src, "-1", "x=-1")]
-
- [coords_x] -
-
[button_element(src, "1", "x=1")]
-
[button_element(src, "10", "x=10")]
-
[button_element(src, "100", "x=100")]
- --- -
-
- "} - - // Y selector - content += {" -
- - Y-Axis - -
-
[button_element(src, "-100", "y=-100")]
-
[button_element(src, "-10", "y=-10")]
-
[button_element(src, "-1", "y=-1")]
-
- [coords_y] -
-
[button_element(src, "1", "y=1")]
-
[button_element(src, "10", "y=10")]
-
[button_element(src, "100", "y=100")]
- --- -
-
- "} - - // Ping button - content += {" -
- - Ping - -
- [ping_result] -
-
- [button_element(src, "PING", "ping=1")] -
-
- "} - - // Summoner - content += {" -
- - Summon - -
- [status] -
-
- [button_element(src, "SUMMON", "summon_selected=1")] -
-
- "} - - // Close coordinates fieldset - content += "
" - - // Asteroids list fieldset - content += {" -
- - Celestial Bodies - - "} - // Selected asteroid container - var/asteroid_name - var/asteroid_desc - if(selected_template) - asteroid_name = selected_template.name - asteroid_desc = jointext(selected_template.get_description(), "") - - content += {" -
-
- [asteroid_name || "N/A"] -
- [asteroid_desc ? "
[asteroid_desc]
" : "
N/A
"] -
- "} - - // Asteroid list container - content += {" -
- "} - - var/i = 0 - for(var/datum/mining_template/template as anything in available_templates) - i++ - var/bg_color = i % 2 == 0 ? "#7c5500" : "#533200" - if(selected_template == template) - bg_color = "#e67300 !important" - content += {" -
- [template.name] ([template.x], [template.y]) -
- "} - - content += "
" - - content += {" - - "} - - - var/datum/browser/popup = new(user, "asteroidmagnet", name, 920, 475) - popup.set_content(jointext(content,"")) - popup.set_window_options("can_close=1;can_minimize=1;can_maximize=0;can_resize=1;titlebar=1;") - popup.open() - /obj/machinery/asteroid_magnet/proc/ping(coords_x, coords_y) var/datum/mining_template/T = map.return_coordinate(coords_x, coords_y) if(T && !T.found) @@ -263,9 +86,9 @@ if(dx < 0) // If the X-axis distance is negative, put it between 181 and 359. 180 and 360/0 are impossible, as that requires X == 0. angle = 360 - angle - ping_result = "AZIMUTH
[round(angle, 0.01)]" + ping_result = "AZIMUTH [round(angle, 0.01)]" else - ping_result = "ERR" + ping_result = "UKNOWN ERROR, NO ASTEROIDS DETECTED. PLEASE CONTACT CENTCOM TECHNICIANS" /// Test to see if we should clear the magnet area. /// Returns FALSE if it can clear, returns a string error message if it can't. @@ -404,5 +227,133 @@ while (collisions <= MAX_COLLISIONS_BEFORE_ABORT) +/obj/machinery/asteroid_magnet/ui_interact(mob/user, datum/tgui/ui) + . = ..() + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "AsteroidMagnet") + ui.open() + ui.set_autoupdate(TRUE) + +/obj/machinery/asteroid_magnet/ui_data(mob/user) + . = ..() + var/list/data = list() + + data["coords_x"] = coords_x + data["coords_y"] = coords_y + data["ping_result"] = ping_result + data["Auto_pinging"] = Auto_pinging + + var/list/asteroid_data = list() + for(var/datum/mining_template/asteroid as anything in available_templates) + asteroid_data += list(list( + "name" = "[asteroid.name] ([asteroid.x] [asteroid.y])", + "ref" = REF(asteroid), + "size" = asteroid.size, + "rarity" = asteroid.rarity, + )) + data["asteroids"] = asteroid_data + + return data + +/obj/machinery/asteroid_magnet/ui_act(action, list/params) // im sorry for this code + . = ..() + if (.) + return + + var/list/map_offsets = map.return_offsets() + var/list/map_bounds = map.return_bounds() + switch(action) + +// X COORDINATES + if("0x") + coords_y = 0 + if(Auto_pinging) + ping(coords_x, coords_y) + + if("-1x") + coords_x = WRAP(coords_x + map_offsets[1] + -1, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + if("-10x") + coords_x = WRAP(coords_x + map_offsets[1] + -10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + if("-100x") + coords_x = WRAP(coords_x + map_offsets[1] + -10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + + if("+1x") + coords_x = WRAP(coords_x + map_offsets[1] + 1, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + if("+10x") + coords_x = WRAP(coords_x + map_offsets[1] + 10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + if("+100x") + coords_x = WRAP(coords_x + map_offsets[1] + 100, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + coords_x -= map_offsets[1] + if(Auto_pinging) + ping(coords_x, coords_y) + +/// Y COORDINATES + + if("0y") + coords_y = 0 + if(Auto_pinging) + ping(coords_x, coords_y) + + if("-1y") + coords_y = WRAP(coords_y + map_offsets[2] + -1, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + if("-10y") + coords_y = WRAP(coords_y + map_offsets[2] + -10, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + if("-100y") + coords_y = WRAP(coords_y + map_offsets[2] + -100, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + + if("+1y") + coords_y = WRAP(coords_y + map_offsets[2] + 1, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + if("+10y") + coords_y = WRAP(coords_y + map_offsets[2] + 10, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + if("+100y") + coords_y = WRAP(coords_y + map_offsets[2] + 100, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y -= map_offsets[2] + if(Auto_pinging) + ping(coords_x, coords_y) + +// OTHER SHIT + + if("TogglePinging") + Auto_pinging = !Auto_pinging + + if("ping") + ping(coords_x, coords_y) + + if("select") + var/datum/mining_template/asteroid = locate(params["asteroid_reference"]) in available_templates + selected_template = asteroid + summon_sequence(selected_template) + #undef MAX_COLLISIONS_BEFORE_ABORT #undef STATUS_OKAY diff --git a/tgui/packages/tgui/interfaces/AsteroidMagnet.js b/tgui/packages/tgui/interfaces/AsteroidMagnet.js new file mode 100644 index 000000000000..4705241a00a5 --- /dev/null +++ b/tgui/packages/tgui/interfaces/AsteroidMagnet.js @@ -0,0 +1,115 @@ +// THIS IS A MONKESTATION UI FILE + +import { useBackend } from '../backend'; +import { Box, Button, LabeledList, Section } from '../components'; +import { Window } from '../layouts'; + +export const AsteroidMagnet = (props, context) => { + return ( + + + + + + + + + ); +}; + +const InputX = (props, context) => { + const { act, data } = useBackend(context); + const { coords_x } = data; + + return ( +
+ + {coords_x} + + +
+ ); +}; + +const InputY = (props, context) => { + const { act, data } = useBackend(context); + const { coords_y } = data; + + return ( +
+ + {coords_y} + + +
+ ); +}; + +const PingButton = (props, context) => { + const { act, data } = useBackend(context); + const { ping_result, Auto_pinging } = data; + + return ( +
+ + {ping_result} + + +
+ ); +}; + +const AsteroidSelector = (props, context) => { + const { act, data } = useBackend(context); + const { asteroids } = data; + + return ( +
+ {asteroids.length > 0 && ( + + {asteroids.map((asteroids) => ( + + act('select', { asteroid_reference: asteroids.ref }) + } + /> + } + /> + ))} + + )} +
+ ); +}; From 85aa1127bba2c029ae5be475c0e7b59eb3a17c60 Mon Sep 17 00:00:00 2001 From: Gboster-0 <82319946+Gboster-0@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:25:17 +0100 Subject: [PATCH 3/4] small TGUI fix --- .../code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm index 6e57c5661999..a6b86f055573 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm @@ -267,7 +267,7 @@ // X COORDINATES if("0x") - coords_y = 0 + coords_x = 0 if(Auto_pinging) ping(coords_x, coords_y) From 971cc84a02099377877aa8f60cbac72e627cbde1 Mon Sep 17 00:00:00 2001 From: Gboster-0 <82319946+Gboster-0@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:26:58 +0100 Subject: [PATCH 4/4] lets use nuclear payloads to remove some unnecessary code --- .../asteroids/asteroid_magnet.dm | 88 ++++--------------- .../tgui/interfaces/AsteroidMagnet.js | 70 ++++++++++++--- 2 files changed, 73 insertions(+), 85 deletions(-) diff --git a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm index a6b86f055573..82014ce46e2c 100644 --- a/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm +++ b/monkestation/code/modules/art_sci_overrides/asteroids/asteroid_magnet.dm @@ -264,85 +264,31 @@ var/list/map_offsets = map.return_offsets() var/list/map_bounds = map.return_bounds() switch(action) - -// X COORDINATES - if("0x") - coords_x = 0 - if(Auto_pinging) - ping(coords_x, coords_y) - - if("-1x") - coords_x = WRAP(coords_x + map_offsets[1] + -1, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - if(Auto_pinging) - ping(coords_x, coords_y) - if("-10x") - coords_x = WRAP(coords_x + map_offsets[1] + -10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - if(Auto_pinging) - ping(coords_x, coords_y) - if("-100x") - coords_x = WRAP(coords_x + map_offsets[1] + -10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - if(Auto_pinging) - ping(coords_x, coords_y) - - if("+1x") - coords_x = WRAP(coords_x + map_offsets[1] + 1, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - if(Auto_pinging) - ping(coords_x, coords_y) - if("+10x") - coords_x = WRAP(coords_x + map_offsets[1] + 10, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) - coords_x -= map_offsets[1] - if(Auto_pinging) - ping(coords_x, coords_y) - if("+100x") - coords_x = WRAP(coords_x + map_offsets[1] + 100, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) + if("Change X Coordinates") + var/amount = params["Position_Change"] + if(amount == 0) // if position change is zero, we are trying to reset the coordinates instead of changing them + coords_x = 0 + if(Auto_pinging) + ping(coords_x, coords_y) + return + + coords_x = WRAP(coords_x + map_offsets[1] + amount, map_bounds[1] + map_offsets[1], map_bounds[2] + map_offsets[1]) coords_x -= map_offsets[1] if(Auto_pinging) ping(coords_x, coords_y) -/// Y COORDINATES + if("Change Y Coordinates") + var/amount = params["Position_Change"] + if(amount == 0) // if position change is zero, we are trying to reset the coordinates instead of changing them + coords_y = 0 + if(Auto_pinging) + ping(coords_x, coords_y) + return - if("0y") - coords_y = 0 - if(Auto_pinging) - ping(coords_x, coords_y) - - if("-1y") - coords_y = WRAP(coords_y + map_offsets[2] + -1, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - if(Auto_pinging) - ping(coords_x, coords_y) - if("-10y") - coords_y = WRAP(coords_y + map_offsets[2] + -10, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - if(Auto_pinging) - ping(coords_x, coords_y) - if("-100y") - coords_y = WRAP(coords_y + map_offsets[2] + -100, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - if(Auto_pinging) - ping(coords_x, coords_y) - - if("+1y") - coords_y = WRAP(coords_y + map_offsets[2] + 1, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - if(Auto_pinging) - ping(coords_x, coords_y) - if("+10y") - coords_y = WRAP(coords_y + map_offsets[2] + 10, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) + coords_y = WRAP(coords_y + map_offsets[2] + amount, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) coords_y -= map_offsets[2] if(Auto_pinging) ping(coords_x, coords_y) - if("+100y") - coords_y = WRAP(coords_y + map_offsets[2] + 100, map_bounds[3] + map_offsets[2], map_bounds[4] + map_offsets[2]) - coords_y -= map_offsets[2] - if(Auto_pinging) - ping(coords_x, coords_y) - -// OTHER SHIT if("TogglePinging") Auto_pinging = !Auto_pinging diff --git a/tgui/packages/tgui/interfaces/AsteroidMagnet.js b/tgui/packages/tgui/interfaces/AsteroidMagnet.js index 4705241a00a5..fef1d192c6f1 100644 --- a/tgui/packages/tgui/interfaces/AsteroidMagnet.js +++ b/tgui/packages/tgui/interfaces/AsteroidMagnet.js @@ -30,13 +30,34 @@ const InputX = (props, context) => { {coords_x} -