Posted 26 April 2017 - 05:47 PM
How to make a wireless lua prompt:
first: copy the base lua program and edit
to do this, simply run: "copy rom/programs/lua ./wlua"
now type edit wlua
second: locally overwrite read()
type in the following code at the very beginning:
now, for the sending side,
Sender:
create a file named wlua on the sender computer.
edit the file and type the following:
EDIT:what i'm doing on this tutorial:
i'm overwriting the read() function with a custom function that allows me to transmit commands as a string
then, on the other computer i am transmitting the commands so that the host will execute them.
you don't need to include the comments in the code, i will put up a wlua pastebin link in the APIs and utilities
i'm sorry if this is more of a "how i did it" than a tutorial, but it's too late now
first: copy the base lua program and edit
to do this, simply run: "copy rom/programs/lua ./wlua"
now type edit wlua
second: locally overwrite read()
type in the following code at the very beginning:
local port = 1337 //this is very important, it sets the port for the wireless execution, change 1337 to whatever number you want(has to be between 0 and 65535)
local modem = peripheral.find("modem") //this wraps the modem. you'll need this
modem.open(port) //this opens the previously mentioned port
local function read() //this is where we overwrite the read() function
local event,s,r,message,dis = os.pullEvent("modem_message") //this gets messages from the modem
if s == 1337 then //this makes sure you're on the 1337 channel to avoid errors
return message //tells the computer what do do
end //ends the if statement
end //ends the function
save and exit the editor.now, for the sending side,
Sender:
create a file named wlua on the sender computer.
edit the file and type the following:
//start
local send = 1337 //sets the transmit channel, change this to the one in the first program
local rec = 137 //arguably useless
local tArgs = { ... } //grabs args for stuff
local modem = peripheral.find("modem") //looks for the modem, to send things
if #tArgs then print("to use wireless lua prompt, simply type 'wlua' ") //yells at you for arguing with it
else //else
while true do //loops it
local x = read() // sets x to the given input
if x ~= "end()" then //checks x for the end
modem.transmit(send,rec,x) //transmits your variable
else //else
modem.transmit(send,rec,'end()') //transmits the end
break end //breaks the loop and ends the IF statement
end //ends the other IF statement
end //ends the loop
EDIT:what i'm doing on this tutorial:
i'm overwriting the read() function with a custom function that allows me to transmit commands as a string
then, on the other computer i am transmitting the commands so that the host will execute them.
you don't need to include the comments in the code, i will put up a wlua pastebin link in the APIs and utilities
i'm sorry if this is more of a "how i did it" than a tutorial, but it's too late now
Edited on 01 December 2017 - 05:12 PM