mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Refactor of commands
This commit is contained in:
21
old/modules/WarpPoints/src/commands.lua
Normal file
21
old/modules/WarpPoints/src/commands.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local warp_min_distance = warp_min_distance^2
|
||||
local warps = warps
|
||||
local self = self
|
||||
|
||||
commands.add_command('make-warp', 'Make a warp point at your location', {
|
||||
['name']={true,'string-inf'}
|
||||
}, function(event,args)
|
||||
if not game.player then return end
|
||||
local position = game.player.position
|
||||
local name = args.name
|
||||
if name:len() > 40 then player_return({'ExpGamingCore_Command.error-string-len',40},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
|
||||
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
|
||||
self.make_warp_point(position,game.player.surface,game.player.force,name)
|
||||
end)
|
||||
5
old/modules/WarpPoints/src/warp_entities.lua
Normal file
5
old/modules/WarpPoints/src/warp_entities.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
return {
|
||||
{'small-lamp',-3,-2},{'small-lamp',-3,2},{'small-lamp',3,-2},{'small-lamp',3,2},
|
||||
{'small-lamp',-2,-3},{'small-lamp',2,-3},{'small-lamp',-2,3},{'small-lamp',2,3},
|
||||
{'small-electric-pole',-3,-3},{'small-electric-pole',3,3},{'small-electric-pole',-3,3},{'small-electric-pole',3,-3}
|
||||
}
|
||||
4
old/modules/WarpPoints/src/warp_tiles.lua
Normal file
4
old/modules/WarpPoints/src/warp_tiles.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
return {
|
||||
{-3,-2},{-3,-1},{-3,0},{-3,1},{-3,2},{3,-2},{3,-1},{3,0},{3,1},{3,2},
|
||||
{-2,-3},{-1,-3},{0,-3},{1,-3},{2,-3},{-2,3},{-1,3},{0,3},{1,3},{2,3}
|
||||
}
|
||||
Reference in New Issue
Block a user