Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. newPopup=function(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss,invert)
  2. if not invert then
  3. ui.addTextArea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
  4. ui.addTextArea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
  5. else
  6. ui.addTextArea(6969+id,"",targetPlayer,x,y-1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
  7. ui.addTextArea(7979+id,"",targetPlayer,x,y+1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
  8. end
  9. ui.addTextArea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  10. end
  11.  
  12. data={}
  13. items={
  14. plank={x=0,y=0},
  15. ore={x=0,y=0},
  16. }
  17.  
  18. assets={
  19. items={
  20. ['Planks']='15dedea314a.png',
  21. ['Pickaxe']='15dedeadd6a.png',
  22. ['Sword']='15dedeb0514.png',
  23. ['camp_fire']='15dedeb2fb4.png',
  24. ['Stone']='15dedeb7429.png',
  25. }
  26. }
  27.  
  28. tfm.exec.disableAutoTimeLeft()
  29. tfm.exec.disableAutoNewGame()
  30.  
  31. split=function(t,s)
  32. local a={}
  33. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  34. table.insert(a,i)
  35. end
  36. return a
  37. end
  38.  
  39. function eventNewGame()
  40. tfm.exec.snow(140, 10)
  41. tfm.exec.setGameTime(140)
  42.  
  43. xml = tfm.get.room.xmlMapInfo.xml
  44.  
  45. for p in string.gmatch(xml, '<P .-/>') do
  46. for plank in string.gmatch(xml, 'Planks=".-"') do
  47. plank=plank:gsub('Planks="',''):gsub('"','')
  48.  
  49. item=split(plank,",")
  50. items.plank.x=tonumber(item[1])
  51. items.plank.y=tonumber(item[2])
  52. end
  53. end
  54.  
  55. for p in string.gmatch(xml, '<P .-/>') do
  56. for ore in string.gmatch(xml, 'Ores=".-"') do
  57. ore=ore:gsub('Ores="',''):gsub('"','')
  58.  
  59. item=split(ore,",")
  60. items.ore.x=tonumber(item[1])
  61. items.ore.y=tonumber(item[2])
  62. end
  63. end
  64. end
  65.  
  66. function eventLoop(t,r)
  67. tfm.exec.removeImage(id)
  68. for name,v in pairs(tfm.get.room.playerList) do
  69. if not v.isDead then
  70. system.bindKeyboard(name,40,true)
  71. if data[name].cold_timer < os.time()-data[name].cold_time and t > 8000 then
  72. data[name].cold = data[name].cold+math.random(1,2)
  73. data[name].cold_time=math.random(0,3000)
  74. data[name].cold_timer=os.time();
  75. end
  76.  
  77. if data[name].cold >= 100 then
  78. data[name].cold=100
  79. tfm.exec.killPlayer(name)
  80. tfm.exec.addShamanObject (54, v.x, v.y, 2, 0, 0, true)
  81. end
  82.  
  83. ui.addTextArea(0,"",name,8,375,100,12,0x1E90FF,0x1E90FF,nil,true)
  84. if data[name].cold >= 5 then
  85. ui.addTextArea(1,"",name,8,375,data[name].cold,12,0x00BFFF,0x00BFFF,nil,true)
  86. end
  87. ui.addTextArea(2,"Frio/Cold: "..data[name].cold.."%",name,8,372,100,16,0,0,0,true)
  88. end
  89. end
  90. end
  91.  
  92. function eventKeyboard(name,key,down,x,y)
  93. if key == 9 then
  94. if not data[name].openCraft then
  95. newPopup(6,"",name,200,40,39,200,0x1d3b40,0x1d3b40,nil,true)
  96. newPopup(7,"",name,200,42,246,20,0x1d3b40,0x1d3b40,nil,true,true)
  97. data[name].openCraft=true
  98. else
  99. for i=6,7 do
  100. ui.removeTextArea(i)ui.removeTextArea(6969+i)ui.removeTextArea(7979+i)
  101. end
  102. data[name].openCraft=false
  103. end
  104. end
  105.  
  106. if key == 40 then
  107. if data[name].collect_time < os.time()-1200 then
  108. x=x-63
  109. y=y-38
  110. 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
  111. tfm.exec.displayParticle (15, 750, 380, 0, 0, 0, 0, name)
  112. id=tfm.exec.addImage (assets.items['Planks'], "!1", 770, 365, name)
  113. giveItem(name,{name="Planks",count=1})
  114. end
  115.  
  116. x=x+63-21
  117. 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
  118. tfm.exec.displayParticle (15, 750, 380, 0, 0, 0, 0, name)
  119. id=tfm.exec.addImage (assets.items[''], "!1", 770, 365, name)
  120. giveItem(name,{name="Coals",count=1})
  121. end
  122.  
  123. data[name].collect_time=os.time();
  124. end
  125. end
  126. end
  127.  
  128. function giveItem(name,dados)
  129. local newItem=true
  130.  
  131. for id,item in pairs(data[name].inventory) do
  132. if item.name==dados.name then
  133. item.count=item.count+dados.count
  134. newItem=false
  135. end
  136. end
  137.  
  138. if newItem then
  139. table.insert(data[name].inventory,dados)
  140. end
  141. end
  142.  
  143. function eventNewPlayer(name)
  144. data[name]={
  145. havePickaxe=false,
  146. openCraft=false,
  147. cold=0,
  148. cold_time=0,
  149. cold_timer=0,
  150. inventory={
  151. {name="Stone",count=3}
  152. },
  153. collect_time=0
  154. }
  155. end
  156.  
  157. --function eventTextAreaCallback(id,name,link)
  158. -- if link == "buy:pickaxe" then
  159. -- if data[name].planks >= 6 then
  160. -- data[name].planks=data[name].planks-1
  161. -- data[name].havePickaxe=true
  162. -- end
  163. -- end
  164. --end
  165.  
  166. for all in pairs(tfm.get.room.playerList) do eventNewPlayer(all) end
  167. tfm.exec.newGame('@7124314')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement