feat: say commands + temp disable scanner
This commit is contained in:
parent
4927c6433d
commit
5400c4db42
14
chat.lua
14
chat.lua
|
|
@ -88,6 +88,18 @@ local function say(msg)
|
|||
end)
|
||||
end
|
||||
|
||||
local function sayas(plr, msg)
|
||||
dispatch(function(bx)
|
||||
bx.sendMessage(msg, plr, "<>")
|
||||
end)
|
||||
end
|
||||
|
||||
local function sayserver(msg)
|
||||
dispatch(function(bx)
|
||||
bx.sendMessage(msg, "Server", "[]")
|
||||
end)
|
||||
end
|
||||
|
||||
local function faketpa(tgtplr, sender, fakeplr, fakemsg)
|
||||
dispatch(function(bx)
|
||||
local clickEvent = {
|
||||
|
|
@ -146,5 +158,7 @@ return {
|
|||
userBc = userBc,
|
||||
reportLog = reportLog,
|
||||
say = say,
|
||||
sayas = sayas,
|
||||
sayserver = sayserver,
|
||||
faketpa = faketpa,
|
||||
}
|
||||
|
|
|
|||
58
index.lua
58
index.lua
|
|
@ -147,6 +147,27 @@ local cmds = {
|
|||
|
||||
ch.say(msg)
|
||||
end,
|
||||
sayas = function(unm, args)
|
||||
local plr = table.remove(args, 1)
|
||||
local msg = table.concat(args, " ")
|
||||
|
||||
if not plr or #msg == 0 then
|
||||
ch.send(unm, "must specify player and message")
|
||||
return
|
||||
end
|
||||
|
||||
ch.sayas(plr, msg)
|
||||
end,
|
||||
sayserver = function(unm, args)
|
||||
local msg = table.concat(args, " ")
|
||||
|
||||
if #msg == 0 then
|
||||
ch.send(unm, "no message was given")
|
||||
return
|
||||
end
|
||||
|
||||
ch.sayserver(msg)
|
||||
end,
|
||||
faketpa = function(unm, args)
|
||||
local tgtplr = table.remove(args, 1)
|
||||
local sender = table.remove(args, 1)
|
||||
|
|
@ -220,13 +241,13 @@ local function processMessage(unm, msg, hidden)
|
|||
end
|
||||
end
|
||||
|
||||
local function scheduleScan()
|
||||
os.startTimer(2)
|
||||
end
|
||||
-- local function scheduleScan()
|
||||
-- os.startTimer(2)
|
||||
-- end
|
||||
|
||||
local termStreak = 0
|
||||
local termStreakAt = 0
|
||||
local lastPlrList
|
||||
-- local lastPlrList
|
||||
local listeners = {
|
||||
["chat"] = function(username, message, uuid, isHidden)
|
||||
return processMessage(username, message, isHidden)
|
||||
|
|
@ -240,22 +261,24 @@ local listeners = {
|
|||
["playerLeave"] = function(username, dimension)
|
||||
tk.plrs[username] = nil
|
||||
end,
|
||||
["timer"] = function()
|
||||
local plrs = tk:scanRange(16)
|
||||
table.sort(plrs)
|
||||
-- ["timer"] = function()
|
||||
-- scheduleScan()
|
||||
|
||||
local plrList = table.concat(plrs, ", ")
|
||||
if plrList ~= lastPlrList then
|
||||
if #plrs > 0 then
|
||||
ch.reportLog("players in range: " .. plrList, "scan")
|
||||
elseif lastPlrList ~= nil then
|
||||
ch.reportLog("players left range", "scan")
|
||||
end
|
||||
-- local plrs = tk:scanRange(16)
|
||||
-- table.sort(plrs)
|
||||
|
||||
lastPlrList = plrList
|
||||
end
|
||||
-- local plrList = table.concat(plrs, ", ")
|
||||
-- if plrList ~= lastPlrList then
|
||||
-- if #plrs > 0 then
|
||||
-- ch.reportLog("players in range: " .. plrList, "scan")
|
||||
-- elseif lastPlrList ~= nil then
|
||||
-- ch.reportLog("players left range", "scan")
|
||||
-- end
|
||||
|
||||
scheduleScan()
|
||||
-- lastPlrList = plrList
|
||||
-- end
|
||||
-- end,
|
||||
["peripheral_detach"] = function()
|
||||
end,
|
||||
["terminate"] = function()
|
||||
-- should we reset term streak
|
||||
|
|
@ -295,5 +318,4 @@ ch.userBc("Loaded!")
|
|||
ch.reportLog("you are auto subbed to log, welcome!")
|
||||
|
||||
tk:refresh()
|
||||
scheduleScan()
|
||||
evDispatcher()
|
||||
|
|
|
|||
Loading…
Reference in New Issue