SHOW:
|
|
- or go back to the newest paste.
| 1 | -- ############################## | |
| 2 | - | -- msg_receiver test3 |
| 2 | + | -- msg_receiver test4 |
| 3 | ||
| 4 | rednet.open("right")
| |
| 5 | ||
| 6 | function hevo() | |
| 7 | print("hevohevo!")
| |
| 8 | end | |
| 9 | ||
| 10 | while true do | |
| 11 | local sender_id, message, distance = rednet.receive() | |
| 12 | ||
| 13 | local func = loadstring(message) | |
| 14 | setfenv(func, getfenv()) -- change func's environment(_G) to current one. | |
| 15 | local status, err = pcall(func) | |
| 16 | ||
| 17 | if status then -- success | |
| 18 | print("#",sender_id,": ",message)
| |
| 19 | else -- wrong string | |
| 20 | print("(error) #",sender_id,": ",message)
| |
| 21 | end | |
| 22 | end |