Posted 03 March 2015 - 05:13 PM
Hey this is my first post ont this forum,
First of all excuse me if I make some english mistakes (The fact is that I am French and learning english , but that's not what you want to know ^^ ).
So I reccently tried to make a program that uses 'http.get' to receive text from a webpage and then activate redstone.
Here is an example to show what it looks like :
The page 'status' is controlled by a PHP script and returns 2 possible values , here "lights-on" and "lights-off".
It's working actually, but I found that I had to refresh the webpage (status) myself ,using my webbrowser, for it to update !
For example :
1 - The status webpage shows "lights-off"
2 - My program prints "lights-off"
3 - I use my PHP script to change the status
4 - My program is still printing : "lights-off" until I refresh the webpage using my webbrowser
Is there any way to make it work properly ?
Am I doing something wrong ?
And if I made some mistakes feel free to correct me :)/>
Thanks for reading and hope to see your answers ^^
First of all excuse me if I make some english mistakes (The fact is that I am French and learning english , but that's not what you want to know ^^ ).
So I reccently tried to make a program that uses 'http.get' to receive text from a webpage and then activate redstone.
Here is an example to show what it looks like :
while true do
local httpstatus = http.get("http://mywebsite.com/status")
local status = httpstatus.readAll()
print(status)
if(status == "lights-on") then
rs.setOutput("right", true)
elseif (status == "lights-off") then
rs.setOutput("right", false)
end
sleep(1)
httpstatus.close()
end
The page 'status' is controlled by a PHP script and returns 2 possible values , here "lights-on" and "lights-off".
It's working actually, but I found that I had to refresh the webpage (status) myself ,using my webbrowser, for it to update !
For example :
1 - The status webpage shows "lights-off"
2 - My program prints "lights-off"
3 - I use my PHP script to change the status
4 - My program is still printing : "lights-off" until I refresh the webpage using my webbrowser
Is there any way to make it work properly ?
Am I doing something wrong ?
And if I made some mistakes feel free to correct me :)/>
Thanks for reading and hope to see your answers ^^