Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p=peripheral.wrap("right")
- c=peripheral.wrap("left")
- users={}
- timeHandle=nil
- while timeHandle==nil do
- timeHandle = http.get("http://www.timeapi.org/utc/in+one+hours")
- end
- time = timeHandle.readLine()
- day=tonumber(time:sub(9, 10))
- month=tonumber(time:sub(6, 7))
- hour=tonumber(time:sub(12, 13))
- minute=tonumber(time:sub(15, 16))
- sec=tonumber(time:sub(18, 19))
- codeChars={"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
- function saveTab(file,tab)
- fp=fs.open(file,"w")
- fp.write(textutils.serialize(tab))
- fp.close()
- end
- function getTab(file)
- fp=fs.open(file,"r")
- return textutils.unserialize(fp.readAll())
- end
- if fs.exists(".codes")==false then
- codes={}
- saveTab(".codes",codes)
- end
- codes=getTab(".codes")
- if fs.exists(".account")==false then
- account={}
- account["No User"]=0
- saveTab(".account",account)
- end
- account=getTab(".account")
- if fs.exists(".users")==false then
- users={}
- saveTab(".users",users)
- end
- users=getTab(".users")
- function generateCode()
- code=codeChars[math.random(1,#codeChars)]
- for i=1,3 do
- code=code..codeChars[math.random(1,#codeChars)]
- end
- codes=getTab(".codes")
- codes[code]=250
- saveTab(".codes",codes)
- p.newPage()
- p.write(code)
- p.endPage()
- end
- function payin()
- if codes[io.read()] then
- account[user]=250
- users[#users+1]=user
- saveTab(".account",account)
- end
- end
- while true do
- event,arg1,arg2,arg3=os.pullEvent()
- if event=="player" then
- user=arg1
- c.say("Hallo "..user)
- getTab(".account",account)
- if account[user]==nil then
- c.say("Gebe bitte deinen Code ein um am Lotto teilzunehmen :D")
- payin()
- else
- c.say("Du nimmst breits am Lotto teil")
- end
- end
- end
Add Comment
Please, Sign In to add comment