daily pastebin goal
53%
SHARE
TWEET

ComputerCraft Tutorial: CommandComputerTest2

hevohevo Feb 21st, 2015 (edited) 218 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- モニターゲット
  2. local mon = peripheral.wrap("left")
  3.  
  4. -- CommandComputerの位置をゲット
  5. local cx,cy,cz = commands.getBlockPosition()
  6.  
  7. function buildFrame(x,y,z,block_name)
  8.   for i=-1,1 do
  9.     commands.setBlock(x+i,y,z+1,block_name)
  10.   end
  11.   for i=-1,1 do
  12.     commands.setBlock(x+i,y,z-1,block_name)
  13.   end
  14.   for i=-1,1,2 do
  15.     commands.setBlock(x+i,y,z,block_name)
  16.   end
  17. end
  18.  
  19. -- 村人カウンター作成(Closure使用、実行するたびカウントアップ)
  20. function makeCounter(_count)
  21.   local count = _count or 0
  22.   return function()
  23.     count = count + 1
  24.     print(count)
  25.     mon.setCursorPos(1,1)
  26.     mon.write("Summon:")
  27.     mon.setCursorPos(1,2)
  28.     mon.write(" "..tostring(count))
  29.   end
  30. end
  31.  
  32.  
  33. -- ######################################
  34. -- メイン
  35.  
  36. -- モニター初期化
  37. mon.clear()
  38. mon.setTextScale(1)
  39.  
  40. -- カウンター作成
  41. local counter = makeCounter(0)
  42.  
  43. -- 施設建設
  44. buildFrame(cx,cy+1,cz, "minecraft:iron_bars")
  45. commands.setBlock(cx,cy+1,cz,"minecraft:flowing_lava")
  46.  
  47. -- 村人さんかわいそす
  48. while true do
  49.   commands.playsound("mob.endermen.portal","@a")
  50.   commands.summon("Villager", cx,cy+4,cz)
  51.   counter()
  52.   os.sleep(3)
  53. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top