Jump to content




Calling a command, and then getting the text it returns?


  • You cannot reply to this topic
3 replies to this topic

#1 NullSchritt

  • Members
  • 43 posts

Posted 05 May 2013 - 03:59 AM

Hello, I am a total noob, so forgive me if this is a simple question, but how would I go about running a command, and then receiving it's text output, so I could display it on the screen?

I want to make a program that automatically dials 1 stargate to another on my server, by executing a command, the command then says back the status of the dialing process as it dials (normally when a person executes the command, it sends personal messages to them telling them the dailing status of the gate) [chevron 1 locked, chevron 2 locked, chevron 3 locked, dail attempt failed <reason>]

I was wondering how I would go about displaying each line of text on an attached monitor as it was sent back to the computer executing the command.

Really appreciate any advice, thanks!

#2 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 05 May 2013 - 04:01 AM

print(someFunction()) --# Make sure you define a function named someFunction first, or edit this!
BOOM! One-liner.
EDIT: Or if you want to keep the data after you print it:
local data = someFunction() --# Make sure you define a function named someFunction first, or edit this!
print(data)
--# Feel free to use the variable 'data' anywhere after this (though only within this program)


#3 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 05 May 2013 - 08:21 AM

In addition to Shnupbups response, you need to use a "return" in the function if you want to get some value from it.
local function getValue()
  --Do some stuff here...
  return "This is a value"
end

local value = getValue()
print(value) --Prints "This is a value"


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 May 2013 - 11:26 AM

Not at all what was being asked, guys. He wants to handle these responses over time, not just once.

OP, we will need more details about your setup, but it sounds like you could either have the computer handling the stargate write it directly on a screen, or send the messages via rednet to the other computer.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users