Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local command = {
- "на арену",
- "На арену",
- "го пвп",
- }
- local component = require("component")
- local event = require("event")
- local shell = require("shell")
- local fs = require("filesystem")
- local serialization = require("serialization")
- local args = shell.parse(...)
- if not component.isAvailable("chat_box") then print("Установите обычный chat box") return end
- if not component.isAvailable("debug") then print("Установите debug card") return end
- if not component.isAvailable("opencb") then print("Установите командный блок") return end
- local debug = component.debug
- local chat = component.chat_box
- local com_block = component.opencb.execute
- function round(hhh)
- local mul = math.pow( 10, roundDig )
- return ( math.floor( ( hhh * mul ) + 0.5 )/mul )
- end
- function scan(nick)
- local s = {debug.getPlayer(nick).getPosition()}
- return {math.ceil(s[1])-1,math.ceil(s[2]),math.ceil(s[3])-1}
- end
- function start()
- local point = {}
- local i = 1
- local ttt = "§3Установка точек§r: "
- chat.setName("§rL§7§o")
- io.write("Ваш ник: ")
- you = io.read()
- chat.say(ttt .. "*** 1 и 2 - точки комнаты, 3 - точка тп (на pim) ***")
- chat.say(ttt .. "Встав на [1] точку напишите что-нибудь в чат")
- while true do
- local _,_,nick,_ = event.pull("chat_message")
- if you == nick then
- point[i] = scan(you)
- i = i + 1
- if i == 4 then break end
- chat.say(ttt .. "Встав на ["..i.."] точку напишите что-нибудь в чат")
- end
- end
- local file=io.open("/home/point.cfg","w")
- file:write(serialization.serialize(point))
- file:close()
- chat.say(ttt .. "Установка закончена")
- end
- if args[1] == "new" then
- start()
- end
- if not fs.exists("/home/point.cfg") then
- start()
- end
- local file = io.open("/home/point.cfg", "r")
- point = serialization.unserialize(file:read())
- file:close()
- print("Для изменения точек, запустите программу иначе -> [назв. программы] new")
- print("*** Программа запущена ***")
- while true do
- local _,_,nick,mes = event.pull("chat_message")
- for _,com in pairs(command) do
- if mes == com then
- local xyz = scan(nick)
- local flag
- for i = 1,3 do
- if point[1][i] > point[2][i] then
- point[1][i],point[2][i] = point[2][i],point[1][i]
- end
- if (xyz[i] >= point[1][i]) and (xyz[i] <= point[2][i]) then
- else
- flag = true
- break
- end
- end
- -- Этот раздел можно дополнять, например обнулять режим бога, отчищать инвентарь и т.д.
- if not flag then
- com_block("tppos "..nick.." "..point[3][1].." "..point[3][2].." "..point[3][3])
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement