Advertisement
Guest User

VirtualMachineForCCtweaked

a guest
Aug 18th, 2022
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --Virtual machine(assembler) for CC:TWEAKED minecraft
  2. --Created Mangro(HexWorld,JustMangro) not copy!
  3. --If you wanna upgrade it or recreate, in start type
  4. --Mangro creator, (your username) upgraded
  5. tArgs        = {}
  6. tick         = 0.005 -- Operation per second, 0.01
  7. byte         = 255 -- Count of one byte
  8. processor    = {}
  9. processor.ax = 50
  10. processor.bx = 0
  11. processor.cx = 0
  12. processor.pc = 0
  13. processor.cc = 1
  14. flags        = {}
  15. flags.left   = false
  16. flags.right  = false
  17. flags.reset  = false
  18. function runTime() while not flags.reset do
  19. sleep(tick)
  20. print(processor.ax .. " " .. processor.bx .. " " .. processor.cx .. " " .. processor.cc)
  21.    for i=1,#processor do
  22.    if processor[i] > byte then
  23.    error("Processor register is very big")
  24.    end end
  25.   --FLAGS
  26.   if flags.right then
  27.    if processor.cc == 1 then
  28.    processor.ax = processor.ax / 2
  29.    elseif processor.cc == 2 then
  30.    processor.bx = processor.bx / 2
  31.    elseif processor.cc == 3 then
  32.    processor.cx = processor.cx / 2
  33.    else
  34.    runTime()
  35.    end
  36.    flags.right = false
  37.    runTime()
  38.   elseif flags.left then
  39.    if processor.cc == 1 then
  40.    processor.ax = processor.ax * 2
  41.    elseif processor.cc == 2 then
  42.    processor.bx = processor.bx * 2
  43.    elseif processor.cc == 3 then
  44.    processor.cx = processor.cx * 2
  45.    else
  46.    runTime()
  47.    end
  48.    flags.left = false
  49.    runTime()
  50.   end
  51.  end
  52.  return
  53. end
  54. runTime()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement