Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- newPopup=function(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss,invert)
- if not invert then
- ui.addTextArea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
- ui.addTextArea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
- else
- ui.addTextArea(6969+id,"",targetPlayer,x,y-1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
- ui.addTextArea(7979+id,"",targetPlayer,x,y+1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
- end
- ui.addTextArea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
- end
- data={}
- items={
- plank={x=0,y=0},
- ore={x=0,y=0},
- }
- imagesToRemove={}
- assets={
- items={
- ['Planks']='15dedea314a.png',
- ['Pickaxe']='15dedeadd6a.png',
- ['Sword']='15dedeb0514.png',
- ['camp_fire']='15dedeb2fb4.png',
- ['Stone']='15dedeb7429.png',
- }
- }
- tfm.exec.disableAutoTimeLeft()
- tfm.exec.disableAutoNewGame()
- split=function(t,s)
- local a={}
- for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
- table.insert(a,i)
- end
- return a
- end
- function eventNewGame()
- tfm.exec.snow(140, 10)
- tfm.exec.setGameTime(140)
- xml = tfm.get.room.xmlMapInfo.xml
- for p in string.gmatch(xml, '<P .-/>') do
- for plank in string.gmatch(xml, 'Planks=".-"') do
- plank=plank:gsub('Planks="',''):gsub('"','')
- item=split(plank,",")
- items.plank.x=tonumber(item[1])
- items.plank.y=tonumber(item[2])
- end
- end
- for p in string.gmatch(xml, '<P .-/>') do
- for ore in string.gmatch(xml, 'Ores=".-"') do
- ore=ore:gsub('Ores="',''):gsub('"','')
- item=split(ore,",")
- items.ore.x=tonumber(item[1])
- items.ore.y=tonumber(item[2])
- end
- end
- end
- function eventLoop(t,r)
- local ids={}
- for i,img in pairs(imagesToRemove) do
- if img.time < os.time()-img.timeTR then
- tfm.exec.removeImage(img.url)
- table.insert(ids,i)
- end
- end
- for i,v in pairs(ids) do
- table.remove(imagesToRemove,v)
- end
- ids={}
- for name,v in pairs(tfm.get.room.playerList) do
- if not v.isDead then
- system.bindKeyboard(name,40,true)
- if data[name].cold_timer < os.time()-data[name].cold_time and t > 8000 then
- data[name].cold = data[name].cold+math.random(1,2)
- data[name].cold_time=math.random(0,3000)
- data[name].cold_timer=os.time();
- end
- if data[name].cold >= 100 then
- data[name].cold=100
- tfm.exec.killPlayer(name)
- tfm.exec.addShamanObject (54, v.x, v.y, 2, 0, 0, true)
- end
- ui.addTextArea(0,"",name,8,375,100,12,0x1E90FF,0x1E90FF,nil,true)
- if data[name].cold >= 5 then
- ui.addTextArea(1,"",name,8,375,data[name].cold,12,0x00BFFF,0x00BFFF,nil,true)
- end
- ui.addTextArea(2,"Frio/Cold: "..data[name].cold.."%",name,8,372,100,16,0,0,0,true)
- end
- end
- end
- function eventKeyboard(name,key,down,x,y)
- if key == 9 then
- if not data[name].openCraft then
- newPopup(6,"",name,200,40,39,200,0x1d3b40,0x1d3b40,nil,true)
- newPopup(7,"",name,200,42,246,20,0x1d3b40,0x1d3b40,nil,true,true)
- data[name].openCraft=true
- else
- for i=6,7 do
- ui.removeTextArea(i)ui.removeTextArea(6969+i)ui.removeTextArea(7979+i)
- end
- data[name].openCraft=false
- end
- end
- if key == 40 then
- if data[name].collect_time < os.time()-1200 then
- x=x-63
- y=y-38
- if x >= items.plank.x - 20 and x <= items.plank.x + 20 and y >= items.plank.y - 20 and y <= items.plank.y + 20 then
- tfm.exec.displayParticle (15, 750, 380, 0, 0, 0, 0, name)
- id=tfm.exec.addImage (assets.items['Planks'], "!1", 770, 365, name)
- table.insert(imagesToRemove,{time=os.time(),url=id,timeTR=200})
- giveItem(name,{name="Planks",count=1})
- end
- x=x+63-21
- if x >= items.ore.x - 20 and x <= items.ore.x + 20 and y >= items.ore.y - 20 and y <= items.ore.y + 20 and data[name].havePickaxe then
- tfm.exec.displayParticle (15, 750, 380, 0, 0, 0, 0, name)
- id=tfm.exec.addImage (assets.items[''], "!1", 770, 365, name)
- table.insert(imagesToRemove,{time=os.time(),url=id,timeTR=200})
- giveItem(name,{name="Coals",count=1})
- end
- data[name].collect_time=os.time();
- end
- end
- end
- function giveItem(name,dados)
- local newItem=true
- for id,item in pairs(data[name].inventory) do
- if item.name==dados.name then
- item.count=item.count+dados.count
- newItem=false
- end
- end
- if newItem then
- table.insert(data[name].inventory,dados)
- end
- end
- function eventNewPlayer(name)
- data[name]={
- havePickaxe=false,
- openCraft=false,
- cold=0,
- cold_time=0,
- cold_timer=0,
- inventory={
- {name="Stone",count=3}
- },
- collect_time=0
- }
- end
- --function eventTextAreaCallback(id,name,link)
- -- if link == "buy:pickaxe" then
- -- if data[name].planks >= 6 then
- -- data[name].planks=data[name].planks-1
- -- data[name].havePickaxe=true
- -- end
- -- end
- --end
- for all in pairs(tfm.get.room.playerList) do eventNewPlayer(all) end
- tfm.exec.newGame('@7124314')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement