Thanks
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Wireless redstone
Started by lucasarnulphy, 06 December 2012 - 02:55 AMPosted 06 December 2012 - 03:55 AM
Hello, I've tried to made a program to put on redstone wirelessely but it didn't work, can you help me and explain me too how to copy and past code in computercraft
Thanks
Thanks
Posted 06 December 2012 - 04:22 AM
to transfer a message wirelessly you will need to use the rednet modem
to detect redstone you will need to use
here is an example:
sender:
as far as i know you can only paste 10 chars at a time :s
if your on a server either get access to the mods/computercraft/ folder
or upload your code to http://pastebin.com
then take the pastebin.com/xxxxxxxxx
and go into a computer and type this in the shell
you can also check out CCcopy but i havent tried it because i have a github and an auto updater
to detect redstone you will need to use
os.pullEvent("redstone")
now use
rs.getOutput("side")
to return the output of that sidehere is an example:
sender:
rednet.open("top") -- replace the top with the side the modem is on
local on=false
local last=false
while true do
if rs.getOutput("front") then -- replace front with what side you want to send
on=true
else
on=false
end
if on~=last then
rednet.send(4,tostring(on)) -- replace 4 with the receivers id
last=on
end
os.pullEvent("redstone")
end
receiver:rednet.open("top")
while true do
p={rednet.receive()}
if p[1]==6 then -- replace 6 with the senders id
if p[2]=="true" then
rs.setOutput("back",true)
else
rs.setOutput("back",false)
end
end
end
as far as i know you can only paste 10 chars at a time :s
if your on a server either get access to the mods/computercraft/ folder
or upload your code to http://pastebin.com
then take the pastebin.com/xxxxxxxxx
and go into a computer and type this in the shell
pastebin get xxxxxxxxx filename
(where xxxxxxxx be the code in the url)you can also check out CCcopy but i havent tried it because i have a github and an auto updater
Posted 06 December 2012 - 04:25 AM
Thanks
Posted 06 December 2012 - 04:34 AM
Error pastebin bios:338 :1: '=' espected
Posted 06 December 2012 - 04:42 AM
you are supposed to run pastebin program from the shell not the lua promptError pastebin bios:338 :1: '=' espected
Posted 06 December 2012 - 06:31 AM
Thanks but what do you mean by shell ? the windows than opens when you open a computer if it is so it says "no such program"
Posted 06 December 2012 - 06:42 AM
The shell is the first window you see when you rght-click a non-used computer. The one with the ">" :)/> Are you sure you type it like that :Thanks but what do you mean by shell ? the windows than opens when you open a computer if it is so it says "no such program"
pastebin get idOfFile nameOfFile
Posted 06 December 2012 - 06:44 AM
That's the error one receives when http is disabled.
Posted 06 December 2012 - 06:48 AM
Oh yes, you must enble http by editing the mod_computercraft config file and set the line http_enabled="false" to http_enabled="true" or something like that to make it work :)/>
Posted 06 December 2012 - 06:49 AM
Ok thanks do you have a tutorial that shows how to enable http
Posted 06 December 2012 - 06:55 AM
It's explained at the top of this page : http://computercraft.info/wiki/index.php?title=HTTP_(API)Ok thanks do you have a tutorial that shows how to enable http
Posted 06 December 2012 - 07:06 AM
The link doesn't work, can you tell me where is the mod_computercraft config file
Thanks
Thanks
Posted 06 December 2012 - 07:16 AM
Posted 06 December 2012 - 07:38 AM
The receiver work but the sender not :
My sender :
Error bios:338: [string "sender"]:6 'then' expected
My sender :
rednet.open("left")
local on=false
local last=false
while true do
if rs.getOutput("right")
else
on=false
end
if on~=last then
rednet.send(46,tostring(on))
last=on
end
os.pullEvent("redstone")
end
Error bios:338: [string "sender"]:6 'then' expected
Posted 06 December 2012 - 07:44 AM
Expected behavior of this code is to set the variable on to false, and keep it false under every circumstance. It also sets last to false, and if it somehow becomes not false, it sets it equal to on (which is always false) and sends a rednet message containing "false" (the value of tostring(on)).
It repeats the loop every time there is a redstone event.
So, if this is not what you were trying to do (and I guess it is not), then what were you trying to do?
It repeats the loop every time there is a redstone event.
So, if this is not what you were trying to do (and I guess it is not), then what were you trying to do?
Posted 06 December 2012 - 07:52 AM
In the hight of the topic, there is what I want to do, PixelToast answered me and give me an exaample code , when I try to launch the sender code there is an error Error bios:338: [string "sender"]:6 'then' expected
Posted 06 December 2012 - 04:19 PM
Fixed code for you, "then" expected is pretty self-explanatory, all if statements in Lua require the word "then" at the end. I also indented your code.
rednet.open("left")
local on=false
local last=false
while true do
if not rs.getOutput("right") then
on=false
end
if on~=last then
rednet.send(46,tostring(on))
last=on
end
end
Posted 06 December 2012 - 08:16 PM
Yes, that repairs the problem with the missing then. I still don't believe it causes this code to do anything useful, though. And it burns cycles like crazy too.
Please explain exactly what behavior you desire from the code.
That's not a lot of information, but I presume PixelToast's code was an answer to it. Why did you alter it so drastically? It had two very important elements that you don't have in your current loop, a way to change on to true when there was redstone output (though what good that does I still don't know) and the os.pullEvent("redstone") so that the loop only ran when there was a change in the redstone state.put on redstone wirelessely
Please explain exactly what behavior you desire from the code.