mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Warp water check
This commit is contained in:
@@ -97,6 +97,7 @@ main-caption=Warp List
|
|||||||
main-tooltip=Warp List; Must be within __1__ tiles to use
|
main-tooltip=Warp List; Must be within __1__ tiles to use
|
||||||
sub-tooltip=Warps can only be used every __1__ seconds and when within __2__ tiles
|
sub-tooltip=Warps can only be used every __1__ seconds and when within __2__ tiles
|
||||||
too-close=Can't make warp; too close to warp: __1__
|
too-close=Can't make warp; too close to warp: __1__
|
||||||
|
too-close-to-water=Cannot create warp this close to water, please move __1__ tiles away from the water body
|
||||||
last-edit=Last edited by __1__ at __2__\nClick to view on map
|
last-edit=Last edited by __1__ at __2__\nClick to view on map
|
||||||
add-tooltip=Add new warp
|
add-tooltip=Add new warp
|
||||||
confirm-tooltip=Save changes
|
confirm-tooltip=Save changes
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ local Roles = require 'expcore.roles' --- @dep expcore.roles
|
|||||||
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
||||||
local config = require 'config.gui.warps' --- @dep config.gui.warps
|
local config = require 'config.gui.warps' --- @dep config.gui.warps
|
||||||
local Warps = require 'modules.control.warps' --- @dep modules.control.warps
|
local Warps = require 'modules.control.warps' --- @dep modules.control.warps
|
||||||
local format_time = _C.format_time --- @dep expcore.common
|
local format_time, player_return = _C.format_time, _C.player_return --- @dep expcore.common
|
||||||
|
|
||||||
--- Stores all data for the warp gui
|
--- Stores all data for the warp gui
|
||||||
local WrapGuiData = Datastore.connect('WrapGuiData')
|
local WrapGuiData = Datastore.connect('WrapGuiData')
|
||||||
@@ -80,6 +80,17 @@ Gui.element{
|
|||||||
local force_name = player.force.name
|
local force_name = player.force.name
|
||||||
local surface = player.surface
|
local surface = player.surface
|
||||||
local position = player.position
|
local position = player.position
|
||||||
|
|
||||||
|
-- Check if the warp is too close to water
|
||||||
|
local water_tiles = surface.find_tiles_filtered{collision_mask = "water-tile", radius = config.standard_proximity_radius + 1, position = position, limit = 1}
|
||||||
|
if #water_tiles > 0 then
|
||||||
|
player_return({'expcore-commands.command-fail', {'warp-list.too-close-to-water', config.standard_proximity_radius + 1}}, 'orange_red', player)
|
||||||
|
local play_sound = 'utility/wire_pickup'
|
||||||
|
if game.player then game.player.play_sound{path=play_sound} end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create the warp
|
||||||
local warp_id = Warps.add_warp(force_name, surface, position, player.name)
|
local warp_id = Warps.add_warp(force_name, surface, position, player.name)
|
||||||
Warps.make_warp_tag(warp_id)
|
Warps.make_warp_tag(warp_id)
|
||||||
Warps.make_warp_area(warp_id)
|
Warps.make_warp_area(warp_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user