Jump to content




[LUA/Java][ERROR] Program returns 38 as value and error in CMD


1 reply to this topic

#1 unknown1138

  • New Members
  • 11 posts

Posted 26 October 2012 - 12:41 PM

Hey all, I've written this script an for some reason I'm getting a java error on my server CMD and at my client's computer screen I get the value 38 returned when I start this script.

Could anyone tell me what is wrong with the script?

Screenshots
Spoiler

I'm using

Tekkit server 3.1.2

-- variables --
id = 0
state = 0
active = true
---------------
-- functions --
local function cl()
term.clear()
end
local function cp(a,B)/>/>
term.setCursorPos(a,B)/>/>
end
active = true
state = 0
while active == true do
while state == 0 do
  cl()
  cp(1,1)
  textutils.slowWrite("Please enter the ID to connect with.")
  cp(1,3)
  textutils.slowWrite("Computer ID: ")
  sleep(0.5)
  cmd = read()
  if tonumber(cmd) > 0 then
  id = cmd
   cp(1,4)
   textutils.slowWrite("Connecting with ID "..id..".")
   sleep(2)
   state = 1
  else
   cp(1,4)
   textutils.slowWrite("ID must be a number!")
   sleep(1)
   state = 0
  end
end
while state == 1 do
  cl()
  cp(1,1)
  print(":D/>/>_:)/>/>_:D/>/>_:)/>/>_:)/>/>_:)/>/>_-_")
  cp(1,2)
  print("-_ ELEVATOR CPP vBeta.1 -_")
  cp(1,3)
  print("-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_")
  cp(1,5)
  write("CMD: ")
  comd = read()
  if comd == "up" then
   rednet.send(id,"up")
   cp(1,6)
   print("Command sent.")
  end
  if comd == "exit" then
   cp(1,6)
   textutils.slowWrite("shutting down...")
   sleep(2)
   cl()
   cp(1,1)
   print(":OS ROOT:")
   cp(1,3)
   active = false
  end
end
end

Thanks in advance

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 26 October 2012 - 05:45 PM

Nowhere did you do rednet.open("side") to send rednet messages.

EDIT: Rather use functions than using two different while loops:

rednet.open('top')

local function cl()
    term.clear()
end
local function cp(a,B)/>/>
    term.setCursorPos(a,B)/>/>
end

function cID()
    cl()
    cp(1,1)
    textutils.slowWrite("Please enter the ID to connect with.")
    cp(1,3)
    textutils.slowWrite("Computer ID: ")
    id = tonumber(read())
    if type(id) ~= "number" then
        textutils.slowWrite("Please enter a valid number above 0.")
        sleep(2)
        return cID()
    elseif id >= 0 then
        cp(1,4)
        textutils.slowWrite("Connecting with ID "..id..".")
        sleep(2)
        elevator()
    else
        cp(1,4)
        textutils.slowWrite("ID must be positive!")
        sleep(1)
        return cID()
    end
end

function elevator()
    cl()
    cp(1,1)
    print(":D/>/>_:)/>/>_:D/>/>_:)/>/>_:)/>/>_:)/>/>_-_")
    print("-_ ELEVATOR CPP vBeta.1 -_")
    print("-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_")
    cp(1,5)
    write("CMD: ")
    comd = read()
    if comd == "up" then
        rednet.send(id,comd)
        cp(1,6)
        print("Command sent to ID: "..id)
        sleep(2)
        return elevator()
    elseif comd == "exit" then
        cp(1,6)
        textutils.slowWrite("shutting down...")
        sleep(2)
        cl()
        cp(1,1)
        print(":OS ROOT:")
        sleep(2)
        cID()
    else
        textutils.slowWrite("Unknown command.")
        sleep(2)
        return elevator()
    end
end

cID()






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users