Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local side = 4
- local maxStack = 16
- local component = require('component')
- local event = require('event')
- local serialization = require('serialization')
- local redstone = component.redstone
- local chest = component.container_chest
- local tLoot = {
- {'stone', 1},
- {'cobblestone', 16}
- }
- local tBlackList = {
- 'Creeper',
- 'Bat',
- 'Slime',
- 'Skeleton',
- 'Spider',
- 'Zombie',
- 'Enderman',
- 'Witch',
- 'Pig',
- 'Sheep',
- 'Cow',
- 'Chicken',
- 'Wolf'
- }
- local function saveTbl(tbl, fl)
- file = io.open(fl, 'w')
- file:write(serialization.serialize(tbl))
- file:close()
- end
- local function loadTbl(fl)
- file = io.open(fl, 'r')
- if not file then
- file = io.open(fl, 'w')
- file:write('{}')
- return {}
- else
- return serialization.unserialize(file:read('*a'))
- end
- file:close()
- end
- local function check(p)
- for i = 1, #tBlackList do
- if p == tBlackList[i] then
- return false
- end
- end
- return true
- end
- local function findItem(fitem)
- for j = 1, chest.getInventorySize() do
- if chest.getStackInSlot(j) ~= nil then
- if chest.getStackInSlot(j).name == fitem then
- return true, j
- end
- end
- end
- end
- local function rsBlink(s, a)
- for f = 1, a do
- redstone.setOutput(s, 15)
- os.sleep(0)
- redstone.setOutput(s, 0)
- end
- end
- local tDate = loadTbl('players.log')
- while true do
- e, _, _, _, _, player = event.pull()
- if e == 'motion' and check(player) then
- if tDate[player] == nil then
- tDate[player] = os.time()
- end
- if os.time() >= tDate[player] then
- for k = 1, #tLoot do
- status, slot = findItem(tLoot[k][1])
- if status then
- chest.pushItem(side, slot, tLoot[k][2])
- end
- end
- saveTbl(tDate, 'players.log')
- for l = 1, 9 do
- rsBlink(2, maxStack)
- end
- tDate[player] = os.time()+6220800
- end
- elseif e == 'key_down' then
- saveTbl(tDate, 'players.log')
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement