Advertisement
ecco7777

CC Mini Tina Testing

Jan 8th, 2022 (edited)
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.75 KB | None | 0 0
  1. chatLog = {}
  2. for i = 1, 10 do
  3.     chatLog[i] = " "
  4. end
  5. selectMode = "skin"
  6. emotion = 1
  7.  
  8. function saveTab(file, tab)
  9.     fp = fs.open(file, "w")
  10.     fp.write(textutils.serialize(tab))
  11.     fp.close()
  12. end
  13.  
  14. function getTab(file)
  15.     fp = fs.open(file, "r")
  16.     return textutils.unserialize(fp.readAll())
  17. end
  18.  
  19. if fs.exists("bild") == false then
  20.     shell.run("pastebin get SawrHPLY bild")
  21. end
  22. if fs.exists("skin") == false then
  23.     shell.run("pastebin get Qz9j4CFq skin")
  24. end
  25. if fs.exists("loadImage") == false then
  26.     shell.run("pastebin get 3iBE8juA loadImage")
  27. end
  28. if fs.exists("turtlearmee") == false then
  29.     shell.run("pastebin get KCW8FCWG turtlearmee")
  30. end
  31. if fs.exists("scan") == false then
  32.     shell.run("pastebin get nJaq5St4 scan")
  33. end
  34. shell.run("scan")
  35. if fs.exists("update") == false then
  36.     fp = fs.open("update", "a")
  37.     fp.writeLine("shell.run('rm startup')")
  38.     fp.writeLine("shell.run('pastebin get YWNLRSpK startup')")
  39.     fp.writeLine("shell.run('reboot')")
  40.     fp.close()
  41. end
  42. if fs.exists("face") == false then
  43.     fp = fs.open("face", "a")
  44.     fp.writeLine("local args = {...}")
  45.     fp.writeLine(
  46.         "m=peripheral.wrap(args[2]) h=tonumber(args[1]) m.setBackgroundColor(colors.yellow) m.clear() bild=paintutils.loadImage('bild')"
  47.     )
  48.     fp.writeLine("paintutils.drawImage(bild,1,h)")
  49.     fp.close()
  50. end
  51. if fs.exists("playerData") == false then
  52.     playerData = {}
  53.     print("Bitte Lege einen Owner fest:")
  54.     playerData["owner"] = io.read()
  55.     print("Bittle Lege einen Namen fest:")
  56.     playerData["myName"] = io.read()
  57.     saveTab("playerData", playerData)
  58. end
  59. playerData = getTab("playerData")
  60. owner = playerData["owner"]
  61. myName = playerData["myName"]
  62.  
  63. function wrapP(peripheralName)
  64.     if os.version() ~= "CraftOS 1.5" then
  65.         if peripheralName == nil then
  66.             print("Fehler")
  67.         end
  68.         local peripherals = peripheral.getNames()
  69.         local i = 1
  70.         while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
  71.             i = i + 1
  72.         end
  73.         if peripheral.getType(peripherals[i]) == peripheralName then
  74.             return peripheral.wrap(peripherals[i]), peripherals[i]
  75.         else
  76.             return nil
  77.         end
  78.     else
  79.         local sides = {"top", "bottom", "left", "right", "front", "back"}
  80.         for i = 1, #sides do
  81.             if peripheral.getType(sides[i]) == peripheralName then
  82.                 return peripheral.wrap(sides[i]), sides[i]
  83.             end
  84.         end
  85.     end
  86. end
  87.  
  88. function wrapPs(peripheralName)
  89.     periTab = {}
  90.     sideTab = {}
  91.     if peripheralName == nil then
  92.         print("Fehler")
  93.     end
  94.     local peripherals = peripheral.getNames()
  95.     local i2 = 1
  96.     for i = 1, #peripherals do
  97.         if peripheral.getType(peripherals[i]) == peripheralName then
  98.             periTab[i2] = peripheral.wrap(peripherals[i])
  99.             sideTab[i2] = peripherals[i]
  100.             i2 = i2 + 1
  101.         end
  102.     end
  103.     if periTab ~= {} then
  104.         return periTab, sideTab
  105.     else
  106.         return nil
  107.     end
  108.  
  109.     function getPSide(peripheralName)
  110.         if peripheralName == nil then
  111.             print("Fehler")
  112.         end
  113.         local peripherals = peripheral.getNames()
  114.         local i = 1
  115.         while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
  116.             i = i + 1
  117.         end
  118.         if peripheral.getType(peripherals[i]) == peripheralName then
  119.             return peripherals[i]
  120.         else
  121.             return nil
  122.         end
  123.     end
  124. end
  125.  
  126. function wrapper()
  127.     c = wrapP("chat")
  128.     if os.version() == "CraftOS 1.7" then
  129.         c = wrapP("chat_box")
  130.     end
  131.     tb = wrapP("terminal_glasses_bridge")
  132.     if os.version() == "CraftOS 1.7" then
  133.         tb = wrapP("openperipheral_bridge")
  134.     end
  135.     sp = wrapP("speaker")
  136.     pr = wrapP("printer")
  137.     mon, monSide = wrapPs("monitor")
  138.     dr, drSide = wrapP("drive")
  139.     nb = wrapP("note")
  140.     modem, modemSide = wrapPs("modem")
  141.     me = wrapP("tileinterface")
  142.     dr = wrapP("droneInterface")
  143.     mani = wrapP("manipulator")
  144.     ni = wrapP("neuralinterface")
  145.     for i = 1, #modem do
  146.         if modem[i].isWireless then
  147.             rednetSide = modemSide[i]
  148.             rednet.open(rednetSide)
  149.         end
  150.     end
  151. end
  152. wrapper()
  153.  
  154. --   1=normal
  155. -- -40=angry
  156. -- -81=Sad
  157. function loadFace()
  158.     for i = 1, #mon do
  159.         if mon[i].getSize() == 61 then
  160.             m = mon[i]
  161.             shell.run("monitor " .. monSide[i] .. " face " .. emotion .. " " .. monSide[i])
  162.         end
  163.     end
  164. end
  165.  
  166. function loadSkin(arg)
  167.     if mon ~= nil then
  168.         if #mon > 0 then
  169.             if arg ~= nil then
  170.                 if tonumber(arg) == nil then
  171.                     monSideCurrent = arg
  172.                 else
  173.                     monSideCurrent = monSide[arg]
  174.                 end
  175.                 monCurrent = peripheral.wrap(monSideCurrent)
  176.                 if monSideCurrent ~= nil then
  177.                     monCurrent.setTextScale(1)
  178.                     if monCurrent.getSize() == 7 then
  179.                         monCurrent.setTextScale(0.5)
  180.                     end
  181.                     if monCurrent.getSize() == 18 then
  182.                         monCurrent.setTextScale(1)
  183.                     end
  184.                     if monCurrent.getSize() == 29 then
  185.                         monCurrent.setTextScale(2)
  186.                     end
  187.                     if monCurrent.getSize() == 39 then
  188.                         monCurrent.setTextScale(3)
  189.                     end
  190.                     shell.run("monitor " .. monSideCurrent .. " loadImage skin")
  191.                 end
  192.             end
  193.             loadFace()
  194.         end
  195.     end
  196. end
  197.  
  198. function loadInfo(arg)
  199.     if tonumber(arg) == nil then
  200.         monSideCurrent = arg
  201.     else
  202.         monSideCurrent = monSide[arg]
  203.     end
  204.     monCurrent = peripheral.wrap(monSideCurrent)
  205.     if monSideCurrent ~= nil then
  206.         monCurrent.setTextScale(1)
  207.         monXScale, monYScale = monCurrent.getSize()
  208.         if monXScale == 7 then
  209.             monCurrent.setTextScale(0.5)
  210.         end
  211.         if monXScale == 18 then
  212.             monCurrent.setTextScale(1)
  213.         end
  214.         if monXScale == 29 then
  215.             monCurrent.setTextScale(2)
  216.         end
  217.         if monXScale == 39 then
  218.             monCurrent.setTextScale(3)
  219.         end
  220.         monXScale, monYScale = monCurrent.getSize()
  221.         monCurrent.setCursorPos((monXScale - #textutils.formatTime(os.time())) / 2, monYScale / 2)
  222.         monCurrent.write(textutils.formatTime(os.time()))
  223.     end
  224. end
  225.  
  226. if #monSide>0 then
  227.     loadSkin(math.random(1, #monSide))
  228. end
  229.  
  230. function say(message)
  231.     print(message)
  232.     addChatLogLine(message)
  233.     if c ~= nil then
  234.         c.say(myName .. ": " .. message)
  235.         sleep(0.5)
  236.     end
  237.     if tb ~= nil then
  238.         glassesChat(message)
  239.         if os.version() == "CraftOS 1.7" then
  240.             tb.sync()
  241.         end
  242.     end
  243.     if sp ~= nil then
  244.         sp.speak(message)
  245.     end
  246.     if mani~=nil then
  247.         if mani.hasModule("plethora:chat") then
  248.             --mani.say(message)
  249.         end
  250.     end
  251. end
  252.  
  253. function eval(command)
  254.     fp = fs.open("eval", "w")
  255.     fp.write(command)
  256.     fp.close()
  257.     shell.run("eval")
  258.     shell.run("rm eval")
  259. end
  260.  
  261. function addChatLogLine(message)
  262.     if #chatLog >= 11 then
  263.         for i = 1, #chatLog do
  264.             chatLog[i] = chatLog[i + 1]
  265.         end
  266.     end
  267.     chatLog[#chatLog + 1] = message
  268. end
  269.  
  270. function glassesChat(message)
  271.     if message then
  272.         addChatLogLine(myName .. " : " .. message)
  273.     else
  274.         if event == "chat" then
  275.             addChatLogLine(arg1 .. " : " .. arg2)
  276.         end
  277.  
  278.         if event == "chat_death" then
  279.             addChatLogLine(arg1 .. " starb")
  280.         end
  281.  
  282.         if event == "chat_command" then
  283.             addChatLogLine(arg2 .. " : " .. arg1)
  284.         end
  285.  
  286.         if event == "glasses_chat_command" then
  287.             addChatLogLine(arg2 .. " : " .. arg4)
  288.         end
  289.     end
  290.     tb.clear()
  291.     tb.addBox(1, 1, 400, 100, 0x000000, 0.1)
  292.     for i = 1, #chatLog do
  293.         tb.addText(1, i * 8, chatLog[i], 0xffffff)
  294.     end
  295.     if os.version() == "CraftOS 1.7" then
  296.         tb.sync()
  297.     end
  298.     if ni~=nil then
  299.         if ni.hasModule("plethora:glasses") then
  300.             updateNeuralMessageWindow(message)
  301.         end
  302.     end
  303. end
  304.  
  305. function search(args1, args2, args3)
  306.     function stringReplace(source, delString, repString)
  307.         if string.find(source, delString) then
  308.             local stringPos = {string.find(source, delString)}
  309.             source = string.sub(source, 1, stringPos[1] - 1) .. repString .. string.sub(source, stringPos[2] + 1)
  310.         end
  311.         return (source)
  312.     end
  313.  
  314.     function stringReplaceAll(source, delString, repString)
  315.         while string.find(source, delString) do
  316.             local stringPos = {string.find(source, delString)}
  317.             source = string.sub(source, 1, stringPos[1] - 1) .. repString .. string.sub(source, stringPos[2] + 1)
  318.         end
  319.         return (source)
  320.     end
  321.  
  322.     function stringDel(source, delString)
  323.         local stringPos = {string.find(source, delString)}
  324.         source = string.sub(source, 1, stringPos[1] - 1) .. string.sub(source, stringPos[2] + 1)
  325.         return (source)
  326.     end
  327.  
  328.     function stringDelAll(source, delString)
  329.         while string.find(source, delString) do
  330.             source = stringDel(source, delString)
  331.         end
  332.         return source
  333.     end
  334.  
  335.     results = {}
  336.     url = http.get("http://www.bing.com/search?q=" .. stringReplaceAll(args1, " ", "+"))
  337.     html = url.readAll()
  338.  
  339.     i = 255
  340.     while i >= 0 do
  341.         html = stringDelAll(html, "&#" .. tostring(i) .. ";")
  342.         i = i - 1
  343.     end
  344.  
  345.     html = stringDelAll(html, "<strong>")
  346.     html = stringDelAll(html, "</strong>")
  347.     html = stringDelAll(html, "&quot")
  348.     html = stringDelAll(html, ";")
  349.     html = stringDelAll(html, ":")
  350.  
  351.     i = 1
  352.     while string.find(html, "<p>") do
  353.         local stringPos1 = {string.find(html, "<p>")}
  354.         local stringPos2 = {string.find(html, "</p>")}
  355.         results[i] = string.sub(html, stringPos1[2] + 1, stringPos2[1] - 1)
  356.         html = stringDel(html, "<p>")
  357.         html = stringDel(html, "</p>")
  358.         i = i + 1
  359.     end
  360.     amount = 4
  361.     if args2 then
  362.         amount = tonumber(args2)
  363.     end
  364.     num = nil
  365.     if tonumber(args3) == nil then
  366.         for i = 1, amount do
  367.             if results[i] ~= nil then
  368.                 if tb ~= nil then
  369.                     glassesChat("Result:" .. i .. string.sub(results[i], 1, 200))
  370.                     if os.version() == "CraftOS 1.7" then
  371.                         tb.sync()
  372.                     end
  373.                     if c ~= nil then
  374.                         c.say("Result:" .. i .. string.sub(results[i], 1, 200))
  375.                         sleep(0.5)
  376.                     end
  377.                 end
  378.             --say("Result:"..i..string.sub(results[i],1,200))
  379.             end
  380.         end
  381.     else
  382.         num = tonumber(args3)
  383.         print(results[num])
  384.     end
  385. end
  386.  
  387. function addButton(id, data, func)
  388.     button = {}
  389.     button.data = data
  390.     button.func = func
  391.     buttons[id] = button
  392. end
  393.  
  394. function giveItemFromMe(fingerprint, amount)
  395.     fi=fingerprint
  396.     eval("me.exportItem(fi,'up',"..amount..")")
  397. end
  398.  
  399. function loadConfig()
  400.     if fs.exists("config")==false then
  401.         fp=fs.open("config","w")
  402.         fp.writeLine("importDirection='north'")
  403.         fp.writeLine("exportDirection='south'")
  404.         fp.writeLine("windowSizeX=950")
  405.         fp.writeLine("windowSizeY=400")
  406.         fp.close()
  407.     end
  408.     shell.run("config")
  409. end
  410. loadConfig()
  411.  
  412. pageOffset=0
  413.  
  414. function nextPage()
  415.     pageOffset=pageOffset+xMax/20*yMax/20
  416.     showItemSelection(items)
  417. end
  418.  
  419. function prevPage()
  420.     if pageOffset-xMax/20*yMax/20>=0 then
  421.         pageOffset=pageOffset-xMax/20*yMax/20
  422.         showItemSelection(items)
  423.     end
  424. end
  425.  
  426. function showItemSelection(items)
  427.     buttons = {}
  428.     t.clear()
  429.     y = 1
  430.     x = 1
  431.     xMax = windowSizeX
  432.     yMax = windowSizeY
  433.     i1 = 1
  434.     t.addBox(1, 1, xMax, math.ceil(#items / (xMax / 20)) * 20, 0x000000, 0.5)
  435.     while y <= yMax do
  436.         while x <= xMax do
  437.             if items[i1+pageOffset] ~= nil then
  438.                 data = {}
  439.                 data.component = t.addIcon(x, y, items[i1+pageOffset].fingerprint.id, items[i1+pageOffset].fingerprint.dmg)
  440.                 if items[i1+pageOffset].size > 1 then
  441.                     data.text = t.addText(x, y + 10, tostring(items[i1+pageOffset].size), 0)
  442.                 end
  443.  
  444.                 data.item = items[i1+pageOffset]
  445.                 function func(data)
  446.                     giveItemFromMe(data.item.fingerprint, 1)
  447.                     --print(data.item.name)
  448.                     if data.text ~= nil then
  449.                         eval(data.text.setText(data.text.getText() - 1))
  450.                     else
  451.                         data.component.delete()
  452.                     end
  453.                     t.sync()
  454.                 end
  455.                 addButton(data.component.getId(), data, func)
  456.             end
  457.             i1 = i1 + 1
  458.             x = x + 20
  459.         end
  460.         x = 1
  461.         y = y + 20
  462.     end
  463.     t.sync()
  464. end
  465.  
  466. function scanItems()
  467.     if me ~= nil then
  468.         items = me.getAvailableItems()
  469.         itemById = {}
  470.         for i = 1, #items do
  471.             itemById[items[i].fingerprint.id .. "/" .. items[i].fingerprint.dmg] = items[i]
  472.         end
  473.     end
  474. end
  475.  
  476. --neural Interface Glasses
  477. function addNButton(xPos,yPos,buttonText,buttonID,bFunction)
  478.     nRec=ctx.addRectangle(xPos,yPos,#buttonText,10)
  479.     nRec.setColor(0x424242)
  480.     nRec.setAlpha(0.5*0xff)
  481.     nText=ctx.addText({xPos,yPos},buttonText)
  482.     nText.setColor(0xffffff)
  483.     nButton={}
  484.     nButton.text=nText
  485.     nButton.rec=nRec
  486.     nButton.pos={xPos,yPos,xPos+#buttonText,yPos+10}
  487.     nButton.func=bFunction
  488.     nButton.id=buttonID
  489.     table.insert(nButtons,nButton)
  490.     nButtonIndex[buttonID]=#nButtons
  491. end
  492.  
  493. function hideButton(nButton)
  494.     nButton.rec.setAlpha(0)
  495.     nButton.text.setAlpha(0)
  496. end
  497.  
  498. function showButton(nButton)
  499.     nButton.rec.setAlpha(0.5*0xff)
  500.     nButton.text.setAlpha(0.5*0xff)
  501. end
  502.  
  503. function updateNeuralMessageWindow(message)
  504.     for it=1,#chatLog do
  505.         chatText[it].setText(message)
  506.     end
  507. end
  508.  
  509. function toggleNMenu()
  510.     if nMenuShown then
  511.         nMenuShown=0
  512.         clearButtons()
  513.     else
  514.         nMenuShown=1
  515.  
  516.     end
  517. end
  518.  
  519. function clearButtons()
  520.     for ib=1,#nButtons do
  521.         hideButtons(nButtons[ib])
  522.     end
  523. end
  524.  
  525. function setupNeuralOverlay()
  526.     --Buttons
  527.     nButtons={}
  528.     nButtonIndex={}
  529.     ctx=ni.canvas()
  530.     addNButton(1,1,"Menu","menu",toggleNMenu)
  531.     addNButton(1,10,"Clear","clear",clearButtons)
  532.     nMenuShown=false
  533.     --MessageWindow
  534.     msgWin=ctx.addRectangle(1,1,42,11*10,buttonText)
  535.     chatText={}
  536.     for it=1,11 do
  537.         chatText[it]=ctx.addText(1,it*10,"")
  538.         chatText[it].setScale(0.5)
  539.     end
  540. end
  541.  
  542. function executeButton(xPos1,yPos1,xPos2,yPos2)
  543.     for ib=1, #nButtons do
  544.         if xPos1>nButtons[ib].pos[1] and yPos1>nButtons[ib].pos[2] and xPos1<nButtons[ib].pos[3] and yPos1<nButtons[ib].pos[4] then
  545.             nButtons[ib].func()
  546.         end
  547.     end
  548. end
  549.  
  550. --main
  551. while true do
  552.     event, arg1, arg2, arg3, arg4 = os.pullEvent()
  553.  
  554.     --Events
  555.     --say(event)
  556.     if event == "peripheral" then
  557.         pType = arg1
  558.         wrapper()
  559.         say("neue Peripheral " .. peripheral.getType(pType) .. " gefunden.")
  560.  
  561.         if peripheral.getType(pType) == "monitor" then
  562.             loadSkin(arg1)
  563.         end
  564.     end
  565.  
  566.     if event == "monitor_resize" then
  567.         loadSkin(arg1)
  568.         sleep(1)
  569.     end
  570.  
  571.     if event == "glasses_capture" then
  572.         for ig=1,#t.getUsers() do
  573.             t.getCaptureControl(t.getUsers()[ig].uuid).setBackground(0xffffff,0)
  574.         end
  575.         scanItems()
  576.         showItemSelection(items)
  577.     end
  578.  
  579.     if event == "glasses_component_mouse_down" then
  580.         componentId = arg4
  581.         --say(arg4)
  582.         if buttons[componentId] ~= nil then
  583.             if buttons[componentId].func ~= nil then
  584.                 buttons[componentId].func(buttons[componentId].data)
  585.             end
  586.         end
  587.        
  588.     end
  589.  
  590.     if event == "glasses_release" then
  591.         t.clear()
  592.         t.sync()
  593.     end
  594.  
  595.     if ni~=nil then
  596.  
  597.     end
  598.  
  599.     if os.version() == "CraftOS 1.7" then
  600.         if event == "glasses_key_down" then
  601.             if arg4 == 200 then
  602.                 rednet.broadcast("turtle do turtle.forward()")
  603.             end
  604.             if arg4 == 208 then
  605.                 rednet.broadcast("turtle do turtle.back()")
  606.             end
  607.             if arg4 == 203 then
  608.                 rednet.broadcast("turtle do turtle.turnLeft()")
  609.             end
  610.             if arg4 == 205 then
  611.                 rednet.broadcast("turtle do turtle.turnRight()")
  612.             end
  613.             if arg4 == 57 or arg4 == 78 then
  614.                 rednet.broadcast("turtle do turtle.up()")
  615.             end
  616.             if arg4 == 54 or arg4 == 74 then
  617.                 rednet.broadcast("turtle do turtle.down()")
  618.             end
  619.             if arg4 == 211 then
  620.                 rednet.broadcast("turtle do turtle.dig()")
  621.             end
  622.             if arg4 == 29 or arg4 == 157 then
  623.                 rednet.broadcast("turtle do turtle.place()")
  624.             end
  625.             if arg4 == 19 then
  626.                 rednet.broadcast("turtle do shell.run('refuel all()') turtle.select(1) ")
  627.             end
  628.             if arg4 == 42 then
  629.                 rednet.broadcast("turtle do p.toggle()")
  630.             end
  631.             if arg4 == 205 then
  632.                 nextPage()
  633.             end
  634.             if arg4 == 203 then
  635.                 prevPage()
  636.             end
  637.  
  638.             if dr ~= nil then
  639.                 drPos = {dr.getDronePosition()}
  640.                 dr.clearArea()
  641.                 if arg4 == 200 then
  642.                     dr.addArea(drPos[1] + 1, drPos[2], drPos[3])
  643.                 end
  644.                 if arg4 == 208 then
  645.                     dr.addArea(drPos[1] - 1, drPos[2], drPos[3])
  646.                 end
  647.                 if arg4 == 203 then
  648.                     dr.addArea(drPos[1], drPos[2], drPos[3] + 1)
  649.                 end
  650.                 if arg4 == 205 then
  651.                     dr.addArea(drPos[1], drPos[2], drPos[3] - 1)
  652.                 end
  653.                 if arg4 == 57 then
  654.                     dr.addArea(drPos[1], drPos[2] + 1, drPos[3])
  655.                 end
  656.                 if arg4 == 42 or arg4 == 54 then
  657.                     dr.addArea(drPos[1], drPos[2] - 1, drPos[3])
  658.                 end
  659.                 dr.setAction("goTo")
  660.                 sleep(0.5)
  661.             end
  662.         end
  663.     end
  664.  
  665.     if event == "monitor_touch" then
  666.         for i = 1, #mon do
  667.             mon[i].clear()
  668.         end
  669.         if selectMode == "skin" then
  670.             loadSkin(arg1)
  671.         end
  672.         if selectMode == "info" then
  673.             mInfo = arg1
  674.             loadInfo(mInfo)
  675.             infoTimer = os.startTimer(1)
  676.         end
  677.     end
  678.  
  679.     if event == "timer" then
  680.         if arg1 == jumpTimer then
  681.             monCurrent.clear()
  682.             loadSkin(math.random(1, #monSide))
  683.             if message ~= myName .. " stop" then
  684.                 jumpTimer = os.startTimer(2)
  685.             else
  686.                 say("ok")
  687.             end
  688.         end
  689.  
  690.         if arg1 == infoTimer then
  691.             if selectMode == "info" then
  692.                 loadInfo(mInfo)
  693.                 infoTimer = os.startTimer(1)
  694.             end
  695.         end
  696.     end
  697.  
  698.  
  699.  
  700.  
  701.     if event == "chat" or event == "chat_command" or event == "glasses_chat_command" or event == "chat_message" then
  702.         if tb ~= nil then
  703.             glassesChat()
  704.         end
  705.         if event == "chat" then
  706.             player = arg1
  707.             message = arg2
  708.         end
  709.         if event == "chat_message" then
  710.             player = arg2
  711.             message = arg3
  712.         end
  713.         if event == "glasses_chat_command" then
  714.             player = arg2
  715.             message = arg4
  716.         end
  717.         if event == "chat_command" then
  718.             player = arg2
  719.             message = arg1
  720.         end
  721.  
  722.         if rednetSide ~= nil then
  723.             rednet.broadcast("turtle do " .. message)
  724.         end
  725.  
  726.         if string.sub(message, 1, #tostring(myName .. " berechne ")) == myName .. " berechne " then
  727.             fp = fs.open("rechner", "w")
  728.             fp.writeLine("say(tostring(" .. string.sub(message, #tostring(myName .. " berechne ")) .. "))")
  729.             fp.close()
  730.             shell.run("rechner")
  731.         end
  732.  
  733.         if string.sub(message, 1, #tostring(myName .. " bing ")) == myName .. " bing " then
  734.             fp = fs.open("rechner", "w")
  735.             say(string.sub(message, #tostring(myName .. " bing ")))
  736.             search(string.sub(message, #tostring(myName .. " bing ")), 10)
  737.             fp.close()
  738.             shell.run("rechner")
  739.         end
  740.  
  741.         if string.sub(message, 1, #tostring(myName .. " list ")) == myName .. " list " then
  742.             if me ~= nil and tb ~= nil then
  743.                 searchId = string.sub(message, #(myName .. " list ") + 1)
  744.                 scanItems()
  745.                 i2 = 1
  746.                 itemsAlike = {}
  747.                 for i = 1, #items do
  748.                     if string.find(string.lower(items[i].fingerprint.id .. "/" .. items[i].fingerprint.dmg), string.lower(searchId)) then
  749.                         itemsAlike[i2] = items[i].fingerprint.id .. "/" .. items[i].fingerprint.dmg, searchId
  750.                         i2 = i2 + 1
  751.                     end
  752.                 end
  753.  
  754.                 for i = 1, 10 do
  755.                     if itemsAlike[i] ~= nil then
  756.                         say(itemsAlike[i] .. " Amount:" .. itemById[itemsAlike[i]].size)
  757.                     end
  758.                 end
  759.             end
  760.         end
  761.  
  762.         if string.sub(message, 1, #tostring(myName .. " gib mir ")) == myName .. " gib mir " then
  763.             if me ~= nil and tb ~= nil then
  764.                 fingerprint = {}
  765.                 scanItems()
  766.                 fp = fs.open("give", "w")
  767.                 fp.writeLine(
  768.                     "fingerprint=itemById[string.sub(message,#(myName..' gib mir ')+1),string.find(message,",
  769.                     ")-1].fingerprint me.exportItem(fingerprint,'up',tonumber(string.sub(message,string.find(message,",
  770.                     ")+1)))"
  771.                 )
  772.                 fp.close()
  773.                 shell.run("give")
  774.             end
  775.         end
  776.  
  777.         if message == myName .. " update" then
  778.             say("Ok bis gleich")
  779.             shell.run("update")
  780.             shell.run("reboot")
  781.         end
  782.  
  783.         if message == myName .. " jump" then
  784.             say("such mich :)")
  785.             jumpTimer = os.startTimer(2)
  786.         end
  787.  
  788.         if string.find(message, myName .. " notiere") ~= nil then
  789.             say("Ich hoere")
  790.             pr.newPage()
  791.             pr.setPageTitle(string.sub(message, #(myName .. " notiere") + 2))
  792.             y = 1
  793.             while message ~= "schluss" do
  794.                 event, dump, player, dump, message = os.pullEvent("glasses_chat_command")
  795.                 if message ~= "schluss" then
  796.                     x = 1
  797.                     for i = 1, math.floor(#message / 26) + 1 do
  798.                         pr.setCursorPos(1, y)
  799.                         pr.write(string.sub(message, x, x + 26))
  800.                         say(string.sub(message, x, x + 26))
  801.                         y = y + 1
  802.                         x = x + 26
  803.                     end
  804.                 end
  805.             end
  806.             pr.endPage()
  807.         end
  808.  
  809.         if string.find(message, myName .. " lua") ~= nil then
  810.             eval(string.sub(message, #(myName .. " lua") + 2))
  811.         end
  812.  
  813.         if string.find(message, myName .. " shoot") ~= nil and string.find(message, myName .. " shoot at") == nil then
  814.             target = string.sub(message, #(myName .. " shoot") + 2)
  815.             shootAt(target, 5)
  816.         end
  817.  
  818.         if string.find(message, myName .. " shoot at") ~= nil then
  819.             target = textutils.unserialize("{" .. string.sub(message, #(myName .. " shoot at") + 2) .. "}")
  820.             shootAtPos(target, 5)
  821.         end
  822.  
  823.         if string.find(message, myName .. " zeig inv") ~= nil and string.find(message, myName .. " shoot at") == nil then
  824.             showInventory(string.sub(message, #(myName .. " zeig inv") + 2))
  825.         end
  826.  
  827.         if string.find(message, myName .. " scan mobs") ~= nil then
  828.             say("Mobs werden gescannt")
  829.             scanAll("mob")
  830.             for i = 1, #entity.mob do
  831.                 say(entity.mob[i].name)
  832.             end
  833.         end
  834.  
  835.         if string.find(message, myName .. " scan spieler") ~= nil or string.find(message, myName .. " scan player") ~= nil then
  836.             say("Spieler werden gescannt")
  837.             scanAll("player")
  838.             for i = 1, #entity.player do
  839.                 say(entity.player[i].name)
  840.             end
  841.         end
  842.  
  843.         if string.find(message, myName .. " suche mobs") ~= nil then
  844.             say(" Mobs werden gesucht")
  845.             scanPos("mob")
  846.             for i = 1, #eName do
  847.                 say(eName[i] .. "  (" .. ePos[eName[i]].x .. "/" .. ePos[eName[i]].y .. "/" .. ePos[eName[i]].z .. ")")
  848.             end
  849.         end
  850.  
  851.         if string.find(message, myName .. " suche spieler") ~= nil then
  852.             say(" Spieler werden gesucht")
  853.             scanPos("player")
  854.             for i = 1, #eName do
  855.                 say(eName[i] .. "  (" .. ePos[eName[i]].x .. "/" .. ePos[eName[i]].y .. "/" .. ePos[eName[i]].z .. ")")
  856.             end
  857.         end
  858.  
  859.         if string.find(message, myName .. " suche alles") ~= nil then
  860.             say(" Entitys werden gesucht")
  861.             scanPos("all")
  862.             for i = 1, #eName do
  863.                 say(eName[i] .. "  (" .. ePos[eName[i]].x .. "/" .. ePos[eName[i]].y .. "/" .. ePos[eName[i]].z .. ")")
  864.             end
  865.         end
  866.  
  867.         if message == myName .. " sag hallo" then
  868.             say("Hallo :D")
  869.         end
  870.  
  871.         if message == myName .. " du bist fett" then
  872.             say("Ich bin nur stabil gebaut")
  873.             emotion = -40
  874.             loadFace()
  875.         end
  876.  
  877.         if message == myName .. " du bist toll" then
  878.             say("Ich weiss")
  879.             emotion = 1
  880.             loadFace()
  881.         end
  882.  
  883.         if message == myName .. " sei traurig" then
  884.             say("Ok")
  885.             emotion = -81
  886.             loadFace()
  887.         end
  888.  
  889.         if message == myName .. " play music" then
  890.             if drSide ~= nil then
  891.                 if disk.hasAudio(drSide) ~= nil then
  892.                     disk.playAudio(drSide)
  893.                     say("playing: " .. disk.getAudioTitle(drSide))
  894.                 end
  895.             end
  896.         end
  897.  
  898.         if message == myName .. " stop music" then
  899.             if drSide ~= nil then
  900.                 disk.stopAudio(drSide)
  901.             end
  902.         end
  903.  
  904.         if message == myName .. " bau eine armee" then
  905.             if rednetSide ~= nil then
  906.                 if dr ~= nil then
  907.                     if disk.isPresent(drSide) then
  908.                         shell.run("cp turtlearmee disk/startup")
  909.                         say(
  910.                             myName ..
  911.                                 " Ich habe dir ein Turtle Programm auf die Floppy gezogen :). Beachte bitte Folgende schritte zum Aufbau der Armee: 1.Wireless Mining Turtle aufstellen 2.Lege Wireless Mining Turtles in den ersten Slot und Fuel in den zweiten 3.Stell ein Diskdrive mit der Floppydisk auf die Turtle und starte die Turtle neu"
  912.                         )
  913.                     else
  914.                         say(myName .. " leg bitte eine Floppydisk in den Diskdrive")
  915.                     end
  916.                 else
  917.                     say(myName .. ": Stell bitte einen Diskdrive mit einer Floppydisk an mich dran :)")
  918.                 end
  919.             else
  920.                 say(myName .. ": Stell bitte ein Wireless Modem an den Computer")
  921.             end
  922.         end
  923.     end
  924. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement