Posted 09 October 2012 - 01:41 AM
ok so heres the thing i have this awesome code mostly done by cranium and he was a huge help except i really want to better understnad what each thing does and how i could implement it in other code operations i have in mind also since i am the only guy atm on the server who can code at all i am of course getting requests and well im still learning and quite often find my self hitting my head againt a wall lol
so heres what i would like from whoever would care to take it on in the code below if anyone could please add comments explaining what each line does and how it is referenced i mean there are somethings which i of course already understnad like rs.set and rs.get and what not but what i need to understand most like the tables and the function calls those i really need help understanding
also if anyone knows of away aside from pastebin (which requires http get and has been decided is too much risk for the server) to copy paste direct to the in game editor(which sucks) that would be awesome thanks in advance
local sides = {"left", "right", "back", "top"}
local function lights(delay)
if not delay then
for i = 1,#sides do
rs.setOutput(sides[i], true)
end
else
local rand = math.random(1,4)
rs.setOutput(sides[rand],true)
sleep(delay)
rs.setOutput(sides[rand],false)
sleep(delay)
end
end
local function display(side,delay1,delay2)
rs.setOutput(side,true)
sleep(delay1)
rs.setOutput(side,false)
sleep(delay2)
end
lights()
sleep(2)
local event, p1 = os.pullEvent()
if event == "redstone" then
while rs.getInput("front") do –changed to continue loop while there is a redstone signal on the front side
local x = math.random(1,4)
display(sides[x],.5,.5)
end
end
end
i appoligize when i pasted it came out like this and then i tried to add it to bbcode that went unreadable so sorry
oh and please note this code doesnt not work as is i edited it after so dont worry about that it works now just not like this i just didnt have a pastble copy of the new code to add here
so heres what i would like from whoever would care to take it on in the code below if anyone could please add comments explaining what each line does and how it is referenced i mean there are somethings which i of course already understnad like rs.set and rs.get and what not but what i need to understand most like the tables and the function calls those i really need help understanding
also if anyone knows of away aside from pastebin (which requires http get and has been decided is too much risk for the server) to copy paste direct to the in game editor(which sucks) that would be awesome thanks in advance
local sides = {"left", "right", "back", "top"}
local function lights(delay)
if not delay then
for i = 1,#sides do
rs.setOutput(sides[i], true)
end
else
local rand = math.random(1,4)
rs.setOutput(sides[rand],true)
sleep(delay)
rs.setOutput(sides[rand],false)
sleep(delay)
end
end
local function display(side,delay1,delay2)
rs.setOutput(side,true)
sleep(delay1)
rs.setOutput(side,false)
sleep(delay2)
end
lights()
sleep(2)
local event, p1 = os.pullEvent()
if event == "redstone" then
while rs.getInput("front") do –changed to continue loop while there is a redstone signal on the front side
local x = math.random(1,4)
display(sides[x],.5,.5)
end
end
end
i appoligize when i pasted it came out like this and then i tried to add it to bbcode that went unreadable so sorry
oh and please note this code doesnt not work as is i edited it after so dont worry about that it works now just not like this i just didnt have a pastble copy of the new code to add here