mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Test for warp distances
This commit is contained in:
@@ -19,6 +19,7 @@ local warp_tile = 'tutorial-grid'
|
|||||||
local warp_limit = 60
|
local warp_limit = 60
|
||||||
local warp_item = 'discharge-defense-equipment'
|
local warp_item = 'discharge-defense-equipment'
|
||||||
local global_offset = {x=0,y=0}
|
local global_offset = {x=0,y=0}
|
||||||
|
local warp_min_distance = 25
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local _global = global
|
local _global = global
|
||||||
@@ -27,7 +28,7 @@ local module_verbose = false
|
|||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function(self)
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{self=self,warps=global}) end
|
if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{self=self,warps=global,warp_min_distance=warp_min_distance}) end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
local warp_min_distance = warp_min_distance^2
|
||||||
local warps = warps
|
local warps = warps
|
||||||
local self = self
|
local self = self
|
||||||
|
|
||||||
@@ -9,7 +10,11 @@ commands.add_command('make-warp', 'Make a warp point at your location', {
|
|||||||
local name = args.name
|
local name = args.name
|
||||||
if game.player.gui.top[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end
|
if game.player.gui.top[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end
|
||||||
if warps.warps[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end
|
if warps.warps[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end
|
||||||
if position.x^2 + position.y^2 < 100 then player_return({'WarpPoints.too-close'},defines.textcolor.med) return commands.error end
|
for name,warp in pairs(warps.warps) do
|
||||||
|
local dx = position.x-warp.position.x
|
||||||
|
local dy = position.y-warp.position.y
|
||||||
|
if dx^2 + dy^2 < warp_min_distance then player_return({'WarpPoints.too-close'},defines.textcolor.med) return commands.error end
|
||||||
|
end
|
||||||
-- to do add a test for all warps
|
-- to do add a test for all warps
|
||||||
self.make_warp_point(position,game.player.surface,game.player.force,name)
|
self.make_warp_point(position,game.player.surface,game.player.force,name)
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user