Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ocal kasl = {}
- -------------------------------------------------------
- function saveList(tbl, fl) --сохраниение таблицы в файл
- local serialization = require('serialization')
- local file = io.open(fl, 'w')
- file:write(serialization.serialize(tbl))
- file:close()
- end
- function loadList(fl) --загрузка таблицы из файла
- local serialization = require('serialization')
- local component = require('component')
- local x, y = component.gpu.getResolution()
- x = x - 22 y = y - 2
- component.gpu.set(x,y,'developed by Dimon933')
- local file = io.open(fl, 'r')
- if not file then
- file = io.open(fl, 'a')
- else
- return serialization.unserialize(file:read('*a'))
- end
- file:close()
- end
- function addblock () -- добавление новых элементов в список
- local M = {}
- for i = 1, 5 do
- print ('Введите адрес ', i,'-го раздатчика')
- local dispenser = (io.read ())
- local luck = 0
- if (i > 1 and i <= 5) then
- print ('введите шанс выпадения предмета ', i, '-го Уровня')
- luck = io.read ()
- luck = tonumber (luck)
- if (type (luck) ~= 'nil') and((luck>0) and (luck<100)) then
- luck = math.floor(100/luck+0.5) print ('принято', luck)
- else
- if (type (luck) == 'nil') then
- print ('Введено некорректное значение для шанса выпадения предмета ', i, '-го Уровня, устанновлен стандартный шанс выпадения ',math.floor(100/((i-1)*10)+0.5),'%')
- else
- if luck < 0 then
- print ('Введено отрицательное значение для шанса выпадения предмета ', i, '-го Уровня, устанновлен стандартный шанс выпадения ',math.floor(100/((i-1)*10)+0.5),'%')
- else
- print ('Введено значение для шанса выпадения предмета ', i, '-го Уровня больше 100%, устаннвлен стандартный шанс выпадения ',math.floor(100/((i-1)*10)+0.5),'%')
- end
- end
- luck = math.floor((i-1)*10)
- end
- else
- luck = 1
- end
- M[i] = {dispenser = dispenser,luck = luck}
- end
- return M
- end
- function dispenspresent (redstoner)
- redstoner.setOutput(0,15)
- os.sleep (0.2)
- redstoner.setOutput(0,0)
- end
- function GenerateRandom (Lists)
- --r = {{id = '1'},{id = '2'},{id = '4'},{id = '6'},{id = '8'}}
- for i3 = 1, 5 do
- local a = math.random(Lists[i3].luck)
- if a ~= 1 then i3= i3-1 j2 = i3 break end
- j2 = i3
- end
- --print ('выйгрыш ', j2)
- return j2
- end
- ---------------------------------------------------local serialization = require('serialization')
- return kasl
Add Comment
Please, Sign In to add comment