mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
@@ -24,6 +24,7 @@ return {
|
||||
'modules.commands.warnings',
|
||||
'modules.commands.find',
|
||||
'modules.commands.bonus',
|
||||
'modules.commands.home',
|
||||
-- QoL Addons
|
||||
'modules.addons.chat-popups',
|
||||
'modules.addons.damage-popups',
|
||||
|
||||
@@ -82,6 +82,10 @@ Roles.new_role('Moderator','Mod')
|
||||
'command/clear-temp-ban',
|
||||
'command/clear-inventory',
|
||||
'command/bonus',
|
||||
'command/home',
|
||||
'command/home-set',
|
||||
'command/home-get',
|
||||
'command/return',
|
||||
'gui/rocket-info/toggle-active',
|
||||
'gui/rocket-info/remote_launch',
|
||||
}
|
||||
@@ -128,6 +132,10 @@ Roles.new_role('Pay to Win','P2W')
|
||||
'gui/rocket-info/toggle-active',
|
||||
'gui/rocket-info/remote_launch',
|
||||
'command/bonus',
|
||||
'command/home',
|
||||
'command/home-set',
|
||||
'command/home-get',
|
||||
'command/return',
|
||||
}
|
||||
|
||||
Roles.new_role('Donator','Don')
|
||||
|
||||
@@ -53,4 +53,11 @@ cleared=__1__ had all they warnings cleared by __2__.
|
||||
unavailable=They was a problem getting you to spawn, please try again later.
|
||||
|
||||
[expcom-repair]
|
||||
result=__1__ entites were revived and __2__ were healed to max health.
|
||||
result=__1__ entites were revived and __2__ were healed to max health.
|
||||
|
||||
[expcom-home]
|
||||
no-home=You have no home set.
|
||||
no-return=You cant return when home has not yet been used.
|
||||
home-set=Your home point has been set to x: __1__ y: __2__
|
||||
return-set=Your return point has been set to x: __1__ y: __2__
|
||||
home-get=Your home point is at x: __1__ y: __2__
|
||||
70
modules/commands/home.lua
Normal file
70
modules/commands/home.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Global = require 'utils.global'
|
||||
require 'config.expcore-commands.parse_general'
|
||||
|
||||
local homes = {}
|
||||
Global.register(homes,function(tbl)
|
||||
homes = tbl
|
||||
end)
|
||||
|
||||
local function teleport(player,position)
|
||||
local surface = player.surface
|
||||
local pos = surface.find_non_colliding_position('character',position,32,1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(pos,surface)
|
||||
return true
|
||||
end
|
||||
|
||||
local function floor_pos(position)
|
||||
return {
|
||||
x=math.floor(position.x),
|
||||
y=math.floor(position.y)
|
||||
}
|
||||
end
|
||||
|
||||
Commands.new_command('home','Teleports you to your home location')
|
||||
:register(function(player,raw)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[1] then
|
||||
return Commands.error{'expcom-home.no-home'}
|
||||
end
|
||||
local rtn = floor_pos(player.position)
|
||||
teleport(player,home[1])
|
||||
home[2] = rtn
|
||||
Commands.print{'expcom-home.return-set',rtn.x,rtn.y}
|
||||
end)
|
||||
|
||||
Commands.new_command('home-set','Sets your home location to your current position')
|
||||
:register(function(player,raw)
|
||||
local home = homes[player.index]
|
||||
if not home then
|
||||
home = {}
|
||||
homes[player.index] = home
|
||||
end
|
||||
local pos = floor_pos(player.position)
|
||||
home[1] = pos
|
||||
Commands.print{'expcom-home.home-set',pos.x,pos.y}
|
||||
end)
|
||||
|
||||
Commands.new_command('home-get','Returns your current home location')
|
||||
:register(function(player,raw)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[1] then
|
||||
return Commands.error{'expcom-home.no-home'}
|
||||
end
|
||||
local pos = home[1]
|
||||
Commands.print{'expcom-home.home-get',pos.x,pos.y}
|
||||
end)
|
||||
|
||||
Commands.new_command('return','Teleports you to previous location')
|
||||
:register(function(player,raw)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[2] then
|
||||
return Commands.error{'expcom-home.no-return'}
|
||||
end
|
||||
local rtn = floor_pos(player.position)
|
||||
teleport(player,home[2])
|
||||
home[2] = rtn
|
||||
Commands.print{'expcom-home.return-set',rtn.x,rtn.y}
|
||||
end)
|
||||
Reference in New Issue
Block a user