Jump to content




coding errors help?


8 replies to this topic

#1 Xenilis

  • New Members
  • 2 posts

Posted 11 October 2012 - 04:21 AM

this is my code and no matter how many times i tinker with it, it still returns errors help?
this is my code:


while rs.getinput(left, true) do
rs.setOutput(right, true)
sleep(2)
else
print("you dun fucked up!")
break
end

#2 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 11 October 2012 - 04:29 AM

rs.getInput(left, true)
should be
rs.getInput("left")

always concat strings with quotation marks "this is a string" and rs.getInput only receives the input of redstone, it doesnt need a true variable at all so just put the side you need to get the input from

#3 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 11 October 2012 - 04:29 AM

The sides for rs are strings, wrap them in quotes
rs.setOutput("right",true)

EDIT: Ninja'd :P/>

Edited by luanub, 11 October 2012 - 04:30 AM.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 October 2012 - 04:43 AM

Also, you don't have an if, so that else won't do anything but throw errors. What are you trying to accomplish with this code?

#5 Xenilis

  • New Members
  • 2 posts

Posted 11 October 2012 - 04:59 AM

while rs.getinput("left", true) do
rs.setOutput("right",true)
sleep(2)
end
modified it and giving me a attempt to call nill error help?

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 October 2012 - 05:03 AM

Capitalization matters, so rs.getinput and rs.getInput are two different things. The second one is correct.

#7 Hacha

  • New Members
  • 5 posts
  • LocationUkraine

Posted 11 October 2012 - 05:20 AM

Firstly, the party must be in " "
In this situation, use if ... then ... else ... end
Try this program :P/>


if rs.getInput("left", true)
   then
	   rs.setOutput("right", true)
	   sleep(2)
   else
	   print("you dun fucked up!")
end


#8 Hacha

  • New Members
  • 5 posts
  • LocationUkraine

Posted 11 October 2012 - 05:23 AM

it very easy program, and you must use if,
cycles use in heavier programs
and rs.getInput("left", true), can be without true, if you want that the signal was always, true - on signal, false - off signal ;)/>
Good luck in further work with programs :P/>

#9 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 11 October 2012 - 05:30 AM

And to finish it up simply add a while loop and eventPull..
while true do
local e,p1 = os.pullEvent("redstone")
if rs.getInput("left") then
  rs.setOutput("right", true)
  sleep(2)
  rs.setOutput("right", false) -- assuming you will want this to turn it off??
else
  print("you dun fucked up!")
end
end

Edited by luanub, 11 October 2012 - 05:31 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users