Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

squall2044

Members
  • Content Count

    14
  • Joined

  • Last visited

Posts posted by squall2044

  1. Hi all I am trying to write a program to control sgcraft gates and
    am having some trouble with the server side of things heres what I have
    so far:
    ##########################################################################
    local c = require("component")

    local e = require("event")

    local m = c.modem

    local s = c.stargate

    local computer = require("computer")

    ()
    m.open(20)

    m.broadcast(20, "Online.")

    local _, _, f1, port, _, message1 = e.pull("modem_message")

    if message1 == "s.dial('s.localAddress()')" then

      m.send(f1, 20, io.stderr:write("Cannot connect to self."))

     else if message1 == "s.dial('???-??????')" and s.energyAvailable() < s.energyToDial('????-??????') then

       m.send(f1, 10, io.stderr:write("Not enough energy to dial that gate."))

      else if message1 == "s.dial('????-??????')" and s.stargateState() == "Idle" then

        m.send(f1, 20, "Dialing.")

       else if message1 == "s.closeIris()" and s.irisState() ~= "offline" then

         m.send(f1, 20, "Closing Iris.")

        else if message1 == "s.openIris()" and s.irisState() ~= "offline" then

          m.send(f1, 20, "Opening Iris.")

         else if message1 == "s.disconnect()" and s.stargateState() ~= "Idle" then

           m.send(f1, 20, "Disconnecting.")

    ----    else if message1 ==

        else

          m.send(f1, 20, io.stderr:write("Command Not Recognized. PLease wait 30 SECONDS for shutdown"))

         end

        end

       end

      end

     end

    end

    -----print("Hello")


    (message1) ----This is where I am having trouble
    computer.shutdown()
    #########################################################################

    Right now the computer is hooked up to a stargate with an Iris and I cam call the methods
    directly from the computer but I want to run them from a tablet so I can 
    bury the computer and leave it with no screen and a wake message.

    what I want it to do is if I send s.closeIris() the Iris will close but I am just getting a
    /home/dial:37: syntax error near 'computer'

    Can anyone help me?

    Thank you in advance.
     

  2. cant answer your first question but I can the second one if you edit the opencomputers files in the .minecraft directory on your pc then go into the game and REMOVE the Hard Drive/Floppy disk that you edited outside of minecraft and then put it back in remember to close the GUI in between it should reread the folder associated with it and your files will be there. I did this yesterday I moved some files from one computer in one world to another in another world. Had to disassemble my creative tablet though because that was what I was editing. Check your local app store on your phone for an app that will help you. I did find one on the Google play store called Learn Lua.

  3. What you are looking for would go a little like this:

    local t = require("term")

    local pass = "12345"

    if text.trim(t.read({}, {}, {}, "*") == pass then

    ###code goes here###

    else

    ###more code here###

    end

     

     

     

    this came from elsewhere and I have not had a chance to test it as I am at work but putting this at the top of your code

    local e = require("event")

    e.shouldInterrupt = function()

       return false

    end

    should prevent a ctrl+alt+c interrupt

  4. It's not each and every time I send a message it is at certain points in the code.

    Here is the program I have:

     

    local h ="Hello"

    local c = require("component")

    local e = require("event")

    local t = require("term")

    local m = c.modem

    local p = "12345\n"

    local s = c.getPrimary("stargate")


     
    t.clear()


    while true do

    print(e.pull("sgDialIn"))
    print("Incoming Wormhole")

    print("Closing Iris")

    s.closeIris()

    m.open(420) --- Choose whatever port you want

    print(m.isOpen(420))
    print("Channel Open")

    e.pull("sgStargateStateChange")

    os.sleep(5)

    m.broadcast(420, h)

    local _, _, from, port, _, handshake = e.pull("modem_message")

     if handshake == h then

      os.sleep(1)
     
       print("Handshake Succeeded. Awaiting Signal")
      
        m.send(from, 420, "Awaiting Signal. Please enter IDC now.")

         local _, _, from, port, _, message = e.pull("modem_message")

          if message == p then

           print("Code: " ..(message).. " Accpeted, Opening Iris")

            s.openIris()

             os.sleep(3)

              m.send(from, 420, "Iris Open. Welcome Home") --- port must be the same as the one you chose earlier

               print("Welcome Home")

                os.sleep(10)

                 print("Closing Gate")

                  s.disconnect()

                   m.close(420)

     else if message ~= p then ---password must be the same as the one you chose earlier

      os.sleep(2)
       print("Code: " ..(message).." Not Accepted, Disconnecting Gate")

         m.send(from, 420, "IDC Rejected")

          os.sleep(4)

           s.disconnect()

            e.pull("sgStargateStateChange")

             os.sleep(1)

              print("Gate Disconnected, Opening Iris")

               s.openIris()

                print("Good-Bye")

                 m.close(420)

      end

     end

    else if handshake ~= h then

     print("Handshake Failed!")

      os.sleep(1)

       m.send(from, 420, "Go Away")

        os.sleep(1)

         s.disconnect()

          s.openIris()

           m.close(420)

      end

     end

    end

     

    As you can see I am opening the port when there is an incoming wormhole and then closing it again at the end of each section also there is alot of sending instead of broadcasting for security's sake. Thank you so much I made the minor change in the code and it works perfectly now.

  5. Description:

      I am writing a program to automatically control an iris from sgcraft and as such I am opening and closing the same port alot within the same program.

     

    Function:

      I would like to be able to define ports at the top of the program and have it populate through.

    For example instead of:

    local c = require("component")

    local e = reuire("event")

    local m = c.modem

    m.open(123)

    m.broadcast(123, "HI!")

    m.close(123)

     

    It would be great if we could go like this:

    local c = require("component")

    local e = reuire("event")

    local m = c.modem

    local p = "123"

    m.open(p)

    m.broadcast(p, "HI!")

    m.close(p)

     

    It would also allow for easy changeing of the port in large programs.

    Deadline:

      There is no deadline, I'm just tossing you guys an idea.

     

    Additional Information:

      Simply ask me if you have other questions

     

    Have Fun!!!

  6. try this

    c = require("component")
    e = require("event")
    t = require("term")
    local m = c.modem
     
    s = c.getPrimary("stargate")
     
    t.clear()
     
    while true do
    print(e.pull("sgDialIn"))
    print("Incoming Wormhole")
    print("Closing Iris")
    s.closeIris()
    m.open(420) --- Choose whatever port you want
    print("Channel Open")
    e.pull("sgStargateStateChange")
    print("Awaiting Signal")
    m.broadcast(420, "Awaiting Signal.")
    local _, _, from, port, _, message = e.pull("modem_message")
    if message == "12345" then  --- choose whatever password you want
     print("Code Accpeted, Opening Iris")
      s.openIris()
       os.sleep(2)
        m.broadcast(420, "Iris Open") --- port must be the same as the one you chose earlier
         print("Welcome Home")
          os.sleep(10)
           print("Closing Gate")
            s.disconnect()
     else if message ~= "12345" then ---password must be the same as the one you chose earlier
      m.broadcast(420, "Code Rejected") --- port must be the same as the one you chose earlier
       print("Code: " ..(message).." Not Accepted, Disconnecting Gate")
        s.disconnect()
         e.pull("sgStargateStateChange")
          os.sleep(1)
           print("Gate Disconnected, Opening Iris")
            s.openIris()
             print("Good-Bye")
      end
     end
    end
     
     
    tablet:
     
    local component = require("component")
    local event = require("event")
    local m = component.modem -- get primary modem component
    m.open(420) --- port must be the same as the computer
    print(m.isOpen(420)) -- true --- see above though this line is not really needed
    local _, _, from, port, _, message = event.pull("modem_message")
    print(message)
    -- Send some message.
    m.broadcast(420, "12345") --- port and password must be the same as the computer
    -- Wait for a message from another network card.
    local _, _, from, port, _, message = event.pull("modem_message")
    print(message)

     

     

     

    remember to put the computer controlling the iris within range of opencomputers broadcast strength. But also remember that a wireless signal that passes through the stargate comes out the other side at half strength so be sure to be in range at the other side as well.  The changes I made to the code above will allow you to see if your iris computer is within range of the signals. If it doesn't work let me know and I'll try to help you through it.

  7. I'm trying to write a program that checks the power in my Stargate and it's state (connected, idle, etc...) and then turn my reactor on and of accordingly. It works for the power portion but does not seem to care about the of the gate. I also have a config file that is working I'm including it in case anybody notices something wrong with it.

     

    here are the codes:

     

    config file:

    c = require("component")

    e = require("event") ---here in case I choose to write other progams

    r = c.getPrimary("br_reactor")

    s = c.getPrimary("stargate")

    t = require("term")  ---here in case I choose to write other programs 

     

    now the code itself:

     

    dofile("config")

     

    if s.energyAvailable() <= 99999 and

     s.stargateState() == idle then

      r.setActive(true)

    else if s.energyAvailable() == 1000000 or

     s.stargateState() ~= idle then

      r.setActive(false)

     end

    end

     

    -----------------------------------------------------------------------------------------------------------------------------------

    In the end I will be looping it but that i have no problem with except for programming in a "break" key that I have no idea.

     

    For SGCraft methods and events go here: http://www.cosc.canterbury.ac.nz/greg.ewing/minecraft/mods/SGCraft/doc/ComputerCraft.html

     

    As for Big Reactors methods and events I'll edit this when their site comes back online

     

     

     

     

    Thanks in advance for any help you can give.

  8. Hi I'm trying to use a Drone as a M.A.L.P. (Mobile Analytic Laboratory Probe) and my problem is that even if i set the drone.move command to stop at the event horizon it goes through the gate, (which is good), but then it tries to immediately go to the point directly behind the sending gate, (which is not so good). How to I tell the drone to stop moving altogether so that it stops on the other side of the gate? 

  9. hi i'm looking to create and run a program that will automatically close the iris when a connection comes into the gate (figured that out)

    then open it with a message (got that too). the part hat is confuseing me however is how do I filter it so that the program is only looking at what was typed to be sent. e.g. if the code was 12345 how do i get it to read that instead of reading sgMessageReceived "souceaddress" 12345?   

    Code so far:

     

    component = require("component")

    event = require("event")

    sg = component.proxy("...") --- deliberately put the three dots here as it changes

     

    event.pull("sgDialIn")

     sg.closeIris()

    event.pull("sgMessageReceived")

     sg.openIris()

     

     

    thats what I have so far the problem is it opens the gate when it receives any message from the other-side of a gate. Anybody have any ideas?

     

    Edit: Nevermind I got it figured out.

    Useing my gates and 12345 as a test password this is what worked for me:

     
    c = require("component")
    e = require("event")
    s = c.getPrimary("stargate")
     
    e.pull("sgDialIn")
      print("Incoming Wormhole")
        print("Closing Iris")
          s.closeIris()
    e.pull("sgStargateStateChange")
      print("Awaiting Signal")
    local _, remoteAddress, payload = e.pull("sgMessageReceived")
      if payload == "12345" then
        print("Code Accpeted, Opening Iris")
          s.openIris()
    else if payload ~= "12345" then
      print("Code Not Accepted, Disconnecting Gate")
        s.disconnect()
    e.pull("sgStargateStateChange")
      print("Gate Disconnected, Opening Iris")
        s.openIris()
          print("Good-Bye")
      end
    end
     
     
    edit 2
    And more importantly this is wireless:
    Using 420 as the port and 12345 as a test password:
    computer must have a wireless network card
    computer connected to gate needs this program:
     
    c = require("component")
    e = require("event")
    t = require("term")
    local m = c.modem
     
    s = c.getPrimary("stargate")
     
    t.clear()
     
    while true do
    print(e.pull("sgDialIn"))
    print("Incoming Wormhole")
    print("Closing Iris")
    s.closeIris()
    m.open(420) --- Choose whatever port you want
    print("Channel Open")
    e.pull("sgStargateStateChange")
    print("Awaiting Signal")
    local _, _, from, port, _, message = e.pull("modem_message")
    if message == "12345" then  --- choose whatever password you want
     print("Code Accpeted, Opening Iris")
      s.openIris()
       os.sleep(2)
        m.broadcast(420, "Iris Open") --- port must be the same as the one you chose earlier
         print("Welcome Home")
          os.sleep(10)
           print("Closing Gate")
            s.disconnect()
     else if message ~= "12345" then ---password must be the same as the one you chose earlier
      m.broadcast(420, "Code Rejected") --- port must be the same as the one you chose earlier
       print("Code: " ..(message).." Not Accepted, Disconnecting Gate")
        s.disconnect()
         e.pull("sgStargateStateChange")
          os.sleep(1)
           print("Gate Disconnected, Opening Iris")
            s.openIris()
             print("Good-Bye")
      end
     end
    end

     

     

    and on the tablet :

    tablet must haves: wireless network card and keyboard

     

    local component = require("component")
    local event = require("event")
    local m = component.modem -- get primary modem component
    m.open(420) --- port must be the same as the computer
    print(m.isOpen(420)) -- true --- see above though this line is not really needed
    -- Send some message.
    m.broadcast(420, "12345") --- port and password must be the same as the computer
    -- Wait for a message from another network card.
    local _, _, from, port, _, message = event.pull("modem_message")
    print(message)
     
     
    Hope this works for you as well as it has for me.
     
    edit 3: tweaked the code so there is less to change
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.