62 posts
Location
Somewhere over the rainbow
Posted 12 November 2012 - 03:02 PM
Ok, it's been about an hour that i'm trying to fix this! All i want to do is to open my light in night time and turn then off at day time.
Here's the code i've been using, can you tell me what wrong with it.
TimeOn = 18.00
TimeOff = 6.00
start = os.time()
while true do
if (start = TimeOn) then
rs.setOutput("bottom", true)
elseif (start <= TimeOff) then
rs.setOutput("bottom", false)
end
end
715 posts
Posted 12 November 2012 - 03:16 PM
start = TimeOn
has to be
start == TimeOn
The former assigns TimeOn to start, the latter compares it.
Also, I'm not sure, but I think you need to poll the time every now and then.
As it is right now I think start will never change.
Edited on 12 November 2012 - 02:19 PM
8543 posts
Posted 12 November 2012 - 03:27 PM
Try this:
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < timeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 08:53 AM
Try this:
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < timeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
That code gave me an error, it was written :"attemp to compare nil with number" at line 6. Thanks for trying to help me.
I've try to correct the typo error Espen, but it did'nt changed anything… i'm running out of idea.
Should i use some pullEvent?? or even some os.setAlarm() Event?? if it is the case i really don't know how to do it :)/>/> :P/>/>
53 posts
Posted 13 November 2012 - 08:58 AM
Try this:
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < timeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
That code gave me an error, it was written :"attemp to compare nil with number" at line 6. Thanks for trying to help me.
I've try to correct the typo error Espen, but it did'nt changed anything… i'm running out of idea.
Should i use some pullEvent?? or even some os.setAlarm() Event?? if it is the case i really don't know how to do it :)/>/> :P/>/>
Have you tried it like this?
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < TimeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
It should work, if not, please tell me the error.
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 09:08 AM
Try this:
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < timeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
That code gave me an error, it was written :"attemp to compare nil with number" at line 6. Thanks for trying to help me.
I've try to correct the typo error Espen, but it did'nt changed anything… i'm running out of idea.
Should i use some pullEvent?? or even some os.setAlarm() Event?? if it is the case i really don't know how to do it :)/>/> :P/>/>
Have you tried it like this?
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < TimeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
It should work, if not, please tell me the error.
I tryed it and it gave me the error "attemp to compare nil with number". at line 6
53 posts
Posted 13 November 2012 - 09:13 AM
Well, the code is fine so you must have misspelled something.
Make sure you capitalize the variables the same way every time. That is most likely the issue,
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 09:50 AM
a
Well, the code is fine so you must have misspelled something.
Make sure you capitalize the variables the same way every time. That is most likely the issue,
What i think it is, is that the os.time() command return time in ticks and not in number i tried to do
if os.time() >= 0 or os.time() == 12000 then
rs.setOutput("bottom", false) -- should be day as 0 equals sundawn and 12000 equals sunset
else
rs.setOutput("bottom", true) -- obviously if it is not day it is night...
end
but it still did'nt worked so i guess my only option now is to cry… i'm really out of idea.
53 posts
Posted 13 November 2012 - 10:04 AM
The last code I posted work 100% fine, this mean you must have misspelled something when copying it, based on the error you gave me, you must have misstyped the variable name of either TimeOn or TimeOff.
715 posts
Posted 13 November 2012 - 10:18 AM
@crackroach:
Are you trying to get this code running on SMP or on SSP?
If the latter is the case, then you can copy and paste the posted codes here directly into the minecraft folder.
In .minecraft/saves/YOURWORLD/computer there will be numbered folders, each of them representing the ID of a computer in your world.
You can add or edit any files within them with a text editor of your choice while the game is running.
But if you knew this already and you're trying to get it to work in SMP, then just forget what I said. :P/>/>
2088 posts
Location
South Africa
Posted 13 November 2012 - 10:37 AM
Have you tried it like this?
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < TimeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
It should work, if not, please tell me the error.
Works for me… @OP your minecraft must be bugged somehow :/
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 10:48 AM
@crackroach:
Are you trying to get this code running on SMP or on SSP?
If the latter is the case, then you can copy and paste the posted codes here directly into the minecraft folder.
In .minecraft/saves/YOURWORLD/computer there will be numbered folders, each of them representing the ID of a computer in your world.
You can add or edit any files within them with a text editor of your choice while the game is running.
But if you knew this already and you're trying to get it to work in SMP, then just forget what I said. :P/>/>
I'm already doing this for the SSP, i just can't figured out why it's not working, i guess my best chance woud be to connect a RedPower sensor with a redstone cable somehow…
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 10:51 AM
Have you tried it like this?
TimeOn = 18.00
TimeOff = 6.00
while true do
if os.time() >= TimeOn or os.time() < TimeOff then
rs.setOutput("bottom", true)
elseif os.time() >= TimeOff and os.time() < TimeOn then
rs.setOutput("bottom", false)
end
sleep(1.0)
end
It should work, if not, please tell me the error.
Works for me… @OP your minecraft must be bugged somehow :/
I use the last technic pack version, so i guess i should clear my cache? :P/>/>
2088 posts
Location
South Africa
Posted 13 November 2012 - 12:01 PM
I tested both in Tekkit and FeedTheBeast which has CC1.46 - both of work…
62 posts
Location
Somewhere over the rainbow
Posted 13 November 2012 - 12:15 PM
I tested both in Tekkit and FeedTheBeast which has CC1.46 - both of work…
Maybye it's my wirering, usally i'm good at that… probably because i used the jacketed wire…