Created
April 3, 2014 17:23
-
-
Save pingbird/9958823 to your computer and use it in GitHub Desktop.
"this game"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rpg={} | |
| local file=io.open("db/rpg","r") | |
| if file then | |
| rpg=unserialize(file:read("*a")) | |
| if not rpg then | |
| srpg={} | |
| end | |
| end | |
| local function update() | |
| local file=io.open("db/rpg","w") | |
| file:write(serialize(rpg)) | |
| file:close() | |
| end | |
| hook.new("msg",function(user,chan,txt,act) | |
| for k,v in pairs(rpg) do | |
| v.food=math.max(0,v.food-1) | |
| if math.random(1,10)==1 then | |
| v.fat=math.max(0,v.fat-1) | |
| end | |
| end | |
| if act and user.account and chan=="#oc" then | |
| local action,usr=txt:match("^(%S+) (.-)%s*$") | |
| local uacc=user.account | |
| rpg[uacc]=rpg[uacc] or {hp=1000,food=0,fat=100} | |
| uacc=rpg[uacc] | |
| if action=="eats" then | |
| local cn=math.random(-20,50) | |
| if uacc.food>=600 then | |
| uacc.hp=uacc.hp-100 | |
| update() | |
| return true,({ | |
| user.nick.." falls through the floor", | |
| user.nick.." falls down stairs", | |
| user.nick.." fell because he forgot to tie his shoes", | |
| "mcdonalds gave "..user.nick.." the wrong meal", | |
| user.nick.." gets sick from eating too much", | |
| })[math.random(1,5)].." and loses 100 hp ( "..uacc.hp.." now )" | |
| elseif uacc.food>=500 then | |
| uacc.fat=uacc.fat+50 | |
| update() | |
| return true,user.nick.." gains 50 fat ( "..uacc.fat.." now )" | |
| elseif uacc.food>=400 then | |
| uacc.fat=uacc.fat+10 | |
| update() | |
| return true,user.nick.." gains 10 fat ( "..uacc.fat.." now )" | |
| end | |
| uacc.hp=uacc.hp+cn | |
| if cn>0 then | |
| uacc.food=uacc.food+100 | |
| update() | |
| return true,user.nick.." gains "..cn.." hp ( "..uacc.hp.." now )" | |
| elseif cn<0 then | |
| update() | |
| return true,usr.." makes "..user.nick.." constipated and loses "..math.abs(cn).." hp ( "..uacc.hp.." now )" | |
| end | |
| elseif admin.perms[usr] then | |
| local acc=(admin.perms[usr] or {}).account | |
| if acc then | |
| rpg[acc]=rpg[acc] or {hp=1000,food=0,fat=0} | |
| acc=rpg[acc] | |
| if action=="slaps" then | |
| if math.random(1,10)==1 then | |
| return true,user.nick.." misses." | |
| else | |
| local cn=math.random(1,10) | |
| acc.hp=acc.hp-cn | |
| update() | |
| return true,usr.." Loses "..cn.." hp ( "..acc.hp.." now )" | |
| end | |
| elseif action=="stabs" then | |
| if math.random(1,5)==1 then | |
| local cn=math.random(1,10) | |
| uacc.hp=uacc.hp-cn | |
| update() | |
| return true,user.nick.." flails around a bit and loses "..cn.." hp ( "..uacc.hp.." now )" | |
| else | |
| local cn=math.random(1,30) | |
| acc.hp=acc.hp-cn | |
| update() | |
| return true,usr.." loses "..cn.." hp ( "..acc.hp.." now )" | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment