Advertisement
killer64

Untitled

Jul 4th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. local cmdb=peripheral.wrap("left")
  2. local advp=peripheral.wrap("right")
  3. local set=infutil.readPrefs("_cps") or {
  4. greeting="Hello $p!",
  5. }
  6. local player={}
  7. local jet={}
  8. setmetatable(player,{
  9. __index=function(s,n)
  10. return advp.getPlayerByName(n)
  11. end
  12. })
  13. local function prt(txt,plr)
  14. if plr then
  15. cmdb.setCommand("/tell "..plr.." "..tostring(txt))
  16. else
  17. cmdb.setCommand("/say "..tostring(txt))
  18. end
  19. cmdb.runCommand()
  20. end
  21. snet.open()
  22. while true do
  23. local p={os.pullEvent()}
  24. if p[1]=="chat_message" then
  25. local tW = {}
  26. for match in string.gmatch(p[3],"[^ \t]+") do
  27. table.insert(tW,match)
  28. end
  29. setmetatable(tW,{__index=function() return "" end})
  30. if tW[1]=="!rs" then
  31. local state
  32. if tW[3]=="1" or string.lower(tW[3])=="true" or string.lower(tW[3])=="on" then
  33. state=true
  34. elseif tW[3]=="0" or string.lower(tW[3])=="false" or string.lower(tW[3])=="off" then
  35. state=false
  36. end
  37. local s,err=pcall(rs.setOutput,tW[2],state)
  38. if not s then
  39. prt((err or "Unknown error"),p[2])
  40. end
  41. elseif tW[1]=="ping" then
  42. prt("pong")
  43. elseif tW[1]=="!reload" then
  44. prt("Reloading...")
  45. sleep(1)
  46. os.reboot()
  47. elseif tW[1]=="!set" then
  48. if tW[2]=="greeting" then
  49. local st={}
  50. for k,v in pairs(tW) do
  51. if k>2 then
  52. table.insert(st,v)
  53. end
  54. end
  55. set.greeting=table.concat(st," ")
  56. prt("Greeting set!")
  57. else
  58. prt("No such var.")
  59. end
  60. infutil.savePrefs("_cps",set)
  61. elseif tW[1]=="!heal" then
  62. local pl
  63. if tW[2]=="" then
  64. pl=p[2]
  65. else
  66. pl=tW[2]
  67. end
  68. pl=player[pl]
  69. if not pcall(pl.getHealth) then
  70. prt("Error healing player.")
  71. else
  72. pl.heal(20)
  73. end
  74. elseif tW[1]=="!play" then
  75. local pl
  76. local snd
  77. if tW[3]=="" then
  78. snd=2
  79. pl=player[p[2]]
  80. else
  81. snd=3
  82. pl=player[tW[2]]
  83. end
  84. snd=table.concat({unpack(tW,snd)}," ")
  85. if not pcall(pl.getHealth) then
  86. prt("Error locating "..tW[2])
  87. else
  88. local x,y,z=pl.asEntity().getPosition()
  89. local err,dat=pcall(advp.getWorld(pl.asEntity().getWorldID()).playSound,snd,x,y,z,1,1)
  90. if not err then
  91. prt((dat or "Unknown error"),p[2])
  92. end
  93. end
  94. elseif tW[1]=="!calc" then
  95. prt(({pcall(setfenv(loadstring("return "..table.concat({unpack(tW,2)}," ")),math))})[2],p[2])
  96. elseif tW[1]=="!explode" then
  97. local pl
  98. if tW[2]=="" then
  99. pl=player[p[2]]
  100. else
  101. pl=player[tW[2]]
  102. end
  103. if not pcall(pl.getHealth) then
  104. prt("Error exploding "..tW[2])
  105. else
  106. local x,y,z=pl.asEntity().getPosition()
  107. advp.getWorld(pl.asEntity().getWorldID()).explode(x,y,z,4,false,false)
  108. pl.damage(20)
  109. end
  110. elseif tW[1]=="!disk" then
  111. snet.open()
  112. local st={}
  113. for k,v in pairs(tW) do
  114. if k>2 then
  115. table.insert(st,v)
  116. end
  117. end
  118. st=table.concat(st," ")
  119. local err,dat
  120. if tW[2]=="play" then
  121. err,dat=pcall(rednet.broadcast,infutil.compress("diskplay",st))
  122. elseif tW[2]=="stop" then
  123. err,dat=pcall(rednet.broadcast,infutil.compress("diskstop"))
  124. end
  125. if not err then
  126. prt((dat or "Unknown error"),p[2])
  127. end
  128. elseif tW[1]=="!jet" then
  129. prt("GTFO MANDRAKE")
  130. --[[if tW[2]=="" or tW[3]=="" or (tonumber(tW[4])==nil and tW[4]~="") then
  131. prt("Usage: !jet <player> <distance> [deley]")
  132. end
  133. for l1=1,tonumber(tW[3]) do
  134. os.queueEvent("chat_message",p[2],"!explode "..tW[2])
  135. if tW[4]~="" then
  136. sleep(tonumber(tW[4]))
  137. end
  138. end]]
  139. end
  140. elseif p[1]=="player_login" then
  141. prt(({string.gsub(set.greeting,"$p",p[2])})[1])
  142. elseif p[1]=="rednet_message" then
  143. os.queueEvent("chat_message",p[2],p[3])
  144. end
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement