This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Goof's profile picture

[rednet][Email Server][HELP]

Started by Goof, 05 November 2012 - 08:33 AM
Goof #1
Posted 05 November 2012 - 09:33 AM
Hey.


can anyone solve this problem???

Rednet:347: positive number expected



code:
Spoiler

local ID2 = 0

rednet.open("right")

msg = rednet.receive()
print(msg)
ID2 = (msg)

a1, m1 = rednet.receive()
print("msg from - "..a1.." - "..m1)
print(ID2)

rednet.send(ID2, ""..m1.."")   <- problem is here?





HELP PLEASE
Leo Verto #2
Posted 05 November 2012 - 11:16 AM
ID2 is a string message, use
ID2 = tonumber(msg)
instead.
Doyle3694 #3
Posted 05 November 2012 - 11:35 AM
Why create a new thread for the same program? Just ask in the other thread!

Btw, you still got your variable usage wrong
Pharap #4
Posted 05 November 2012 - 12:50 PM
Try running this:


local ID2 = 0
rednet.open("right")
msg = rednet.receive()
print(msg)
ID2 = tonumber(msg)
a1, m1 = rednet.receive()
print("msg from - "..tostring(a1).." - "..tostring(m1))
print(ID2)
rednet.send(ID2, tostring(m1))   <- problem is here?

tostring() converts numbers into strings and
tonumber() converts valid strings to numbers

They are built in lua functions so you can always use them for changing types.
Goof #5
Posted 06 November 2012 - 02:48 AM
Thanks for the quick response… that was REALY helpful! keep the good work!

but. can i make something on the Receive PC, so it receives all time, where u can move in menus, at same time??

like..

i have a menu. and then it receives every 0.2 seconds. but then i want , so i can still scroll in my menu at same time?


is this possible with rednet.receive(0.2) ???

and then i also have 1 problem…

when the server receives the first msg (that should be the ID) then if that msg is empty, then it automatically send it to the pc ID 11, which is the listening computer… why? i did hope it to just return false, cause there isn't any ID to sent the last msg to*?
TechWorm #6
Posted 06 November 2012 - 04:14 AM
Not a pretty easy code but u can make chatsystems instead its more easy :P/>/>
Doyle3694 #7
Posted 06 November 2012 - 04:31 AM
mikk, look up os.pullEvent() :P/>/>
Goof #8
Posted 06 November 2012 - 06:40 AM
yeah i did, but how could i make a program that still receives any messages, while you are in a menu, which you can scroll in???
Leo Verto #9
Posted 06 November 2012 - 07:41 AM
parallels API, look up a tutorial on the forums or on the wiki.
Doyle3694 #10
Posted 06 November 2012 - 09:07 AM
Leo Verto? That is false information right there. parallel API wouldn't work in this instance. you can't parallel yield lol

now for mikk, I think you got water above your head right now. I suggest you put this program on the shelf and start with something abit more basic, like a basic menu. You seem to have almost no land to stand on here and we cant just code it all for you. there is a nice tutorials about os.pullEvent() in the tutorials section too btw. :P/>/>
Goof #11
Posted 06 November 2012 - 10:00 AM
ehm… i know quite a lot about menu making. and i know quite alot about programming.. but the only issue i have right now, in this program, is the Rednet.receive()

and thats my error.

i dont know how to make 2 programs/functions, running at the same time…..

i did think something about. Rednet.receive(until key == pressed ) or something like that…

but thats my only hole in programming with rednet/ programming with 2 functions running at same time.,…


but if you _Can_ (only if you can and will) then tell me how to make 2 things run at same time….


Thanks for all answers.

and i have looked in the os.pullEvent tutorial.. but i dont seems to find my answer there…. :P/>/>
Doyle3694 #12
Posted 06 November 2012 - 10:07 AM
there is a event called rednet_message, and rednet.recieve is really just a extension to it
Goof #13
Posted 06 November 2012 - 10:10 AM
Thanks. But i know that rednet_message and rednet.receive() is close to be the same.. Thanks for your help doyle. Now i will just try to make some tests, and then put it into my menu. Thanks
Doyle3694 #14
Posted 06 November 2012 - 10:38 AM
Check longest down here:
http://computercraft.info/wiki/index.php?title=Os.pullEvent

There is all the events and the arguements for them
Lyqyd #15
Posted 06 November 2012 - 11:07 AM
The parallel API is certainly the wrong tool to use here. Simply check for rednet_message events along with key/char/etc. events in your menu event loop.