Jump to content




rednet.send variable + string


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

#1 NorwayKtm

  • New Members
  • 2 posts
  • LocationGermany

Posted 01 September 2014 - 05:07 PM

Hey all!
I'm trying to rednet.send a variable + string but don't know how this works. :P
shell.run("clear")
term.setTextColor(colors.orange)
print("BackOS 1.5")
print("")
term.setTextColor(colors.white)
print("Wie viel Brot soll ich backen?")
term.setTextColor(colors.blue)
print("[1   |   3   |   6]")
term.setTextColor(colors.white)
local anzahl = io.read()
--This area
rednet.send(13,anzahl)
--*over me*
term.setTextColor(colors.green)
print("Ihr Brot wird nun gebacken")
term.setTextColor(colors.white)
sleep(3)
shell.run("startup")
And I want to send "anzahl" + a custom text.
local anzahl = io.read()
rednet.send(13,anzahl,"hello")

Help please :rolleyes:

#2 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 01 September 2014 - 09:44 PM

A relatively easy way to do this would be to just send the text in the first message and then the contents of the variable in the second.

Alternatively if you really want to send it in one you could do something with string functions. Something like:

local anzahl=io.read()
rednet.send(13,"<anzahl>"..anzahl.."</anzahl>".."hello")

and then on the receiving computer:

temp=string.sub(msg,string.find(msg,"<anzahl>(.-)</anzahl>")) --#removes the "hello" and anything else not included within the <></> tags
temp=string.gsub(temp,"<(.-)>","") --#removes the tags
local anzahl=temp --#returns the variable


#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 01 September 2014 - 09:48 PM

or you could send a table
rednet.send( 13, { anzah1 = anzah1, msg = "hello" } )
local anzah1, other_variable = msg.anzah, msg.msg

Edited by KingofGamesYami, 01 September 2014 - 09:48 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users