Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

LucasLista

Members
  • Content Count

    7
  • Joined

  • Last visited

Posts posted by LucasLista

  1. Ok the code in the end is:

    local robot = require "robot"
    local term = require "term" 
     
    term.write("Please enter password: ")
    a = io.read("*line")
    print(a)
    if a == "Op" then
      print("Meh")
    end

    So I needed both of your tips, the quotes and the io.read() however I can say that term.read({dobreak=false}) does not work. As seen in the code below

    Thanks to both of you, the problem is solved.

     

    term.read({dobreak=false}) does not work:

    local robot = require "robot"
    local term = require "term" 
     
    term.write("Please enter password: ")
    a = term.read({dobreak=false})
    print(a)
    if a == "Op" then
      print("Meh")
    end

    the result was this

    /home # Test
    Please enter password: OpOp
    
    /home #

    I only wrote Op once, it then printed Op again right after and it still made a new line.

     

    But thanks for helping me!

  2. So like this?

    local robot = require "robot"
    local term = require "term" 
     
    term.write("Please enter password: ")
    a = term.read()
    print(a)
    if a == "Meas" then
      print("Meh")
    end

    because that doesn't work... (neither did it work with if I replaced Meas with 1)

    I don't think I exactly understood what you meant, maybe you could show me in code what you are saying?

  3. 7 hours ago, Molinko said:

    io.read and term.read both return a string. Use tonumber(a)==2

    That only works for numbers, I already found a way to do that even though it isn't how it's supposed to be done (a = a+0)

    I need to know how I do it for words.

    F.x

    local robot = require "robot"
    local term = require "term" 
     
    term.write("Please enter password: ")
    a = term.read()
    print(a)
    if a == Meas then
      print("Meh")
    end

    tonumber does not work for words... but thank you for taking some of your time to answer.

     

    btw I thought strings were just numbers?

  4. Hmm, interesting. If I make a new code:

    local robot = require "robot"
    local term = require "term"
    
    term.write("Please enter password: ")
    a = term.read()
    print(a)
    b = a+1
    print(b)
    if b == 2 then
      print("Meh")
    end

    This works, if I write 1 it says meh

    So as you can see in the picture in my original post there's an extra line where it didnt write anything. It must have something to do with that. Because when do a+1 it does not do that extra empty line. 

    But I still need help, because I want to do this with letters instead, and there I can't just do +1.

     

     

    local robot = require "robot"
    local term = require "term" 
     
    term.write("Please enter password: ")
    a = io.read("*line")
    print(a)
    if a == 2 then
      print("Meh")
    end

    This actually doesn't make that extra line, but the if then statement still only works if I do

    b = a+1 ; if b == 2 then

     

     

    if a == 2 then

    Doesn't work

  5. local robot = require "robot"
    local term = require "term"
    
    term.write("Please enter password: ")
    a = term.read()
    print(a)
    if a == 2 then
      print("Meh")
    end

    So when I run the code it obviously asks for my password, so I might write 2, but then it just prints 2 and doesn't print Meh, it knows the value is 2 but the if then statement won't work. 

    2017-09-30_12.58.56.png

  6. So I tried to make my robot place upside-down stairs and I noticed it would only do it when I used robot.placeUp() or robot.placeDown() but in those cases the only way the stairs would face is south (the tall part of the stairs were facing south)

    Is there any way I can make a robot place stairs in a different orientation? I did try to specify a side but then it would work like the robot was placing the block on the side, it wouldn't place the stairs upside-down.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.