This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
justjort's profile picture

Daymaker

Started by justjort, 01 April 2013 - 01:04 AM
justjort #1
Posted 01 April 2013 - 03:04 AM
so i am annoyed of the night when i am in my testworld. so i made a program which would keep it day, by having a command block on the left hand side of the computer. but i got an error, i hope someone could help me out

code:

while true do
if os.time() = 17 then
  redstone.setOutput("left", true)
  sleep(4)
  redstone.setOutput("left", false)
end
end

error:

bios:338: [string "startup"]:2: 'then' expected
JustPingo #2
Posted 01 April 2013 - 03:09 AM
while true do
if os.time() >= 17 or os.time() <= 6 then
redstone.setOutput("left", true)
sleep(4)
redstone.setOutput("left", false)
end
end

2 egals in a if, and it's better like this.
And it's not the better forum to ask this.
theoriginalbit #3
Posted 01 April 2013 - 03:11 AM
for future reference the "Programs" section is for completed programs. The "Ask a Pro" section is the one you would normally post this kind of question on.

now to answer the problem…

= (assignment) is an assignment operator. i.e. it is what you use to store a value into a name to reuse it later
== (equals) is a comparison operator i.e. you use this to compare two values
~= (not equal) is also a comparison operator, it is the opposite of above.

EDIT: Badly formatted html code ninja :ph34r:/> http://puu.sh/2rdbs
Edited on 01 April 2013 - 01:12 AM
JustPingo #4
Posted 01 April 2013 - 03:16 AM
EDIT: Badly formatted html code ninja :ph34r:/>/> http://puu.sh/2rdbs

LOL. I hate Copy/Paste Color Keeper xD

And a

sleep(0)

is needed to stop the "Too long without yielding" error after the while.7

(no more errors xD)
theoriginalbit #5
Posted 01 April 2013 - 03:19 AM
EDIT: Badly formatted html code ninja :ph34r:/> http://puu.sh/2rdbs
LOL. I hate Copy/Paste Color Keeper xD
Use the "Remove Format" button (its the rubber) and it will remove all that for you…
JustPingo #6
Posted 01 April 2013 - 03:21 AM
EDIT: Badly formatted html code ninja :ph34r:/>/>/> http://puu.sh/2rdbs
LOL. I hate Copy/Paste Color Keeper xD
Use the "Remove Format" button (its the rubber) and it will remove all that for you…


AMAZING !
Thanks you sir.

OS : Your WebSite is awesome !
justjort #7
Posted 01 April 2013 - 03:28 AM
thanks for all the help, i got it working now, and i will upload this in a different forum next time :)/>
spyman68 #8
Posted 01 April 2013 - 03:32 AM
Why need a computer to do that? use a daylight sensor, derp
theoriginalbit #9
Posted 01 April 2013 - 03:38 AM
OS : Your WebSite is awesome !
Thank you… all credit goes to GravityScore, he made it, I adapted it a little…


Why need a computer to do that? use a daylight sensor, derp
A daylight sensor needs to be able to see the sky. a computer does not. I actually made a similar script a while ago for #WHYISTHISNOTWORKING http://pastebin.com/1hyEG2BL