Jump to content




read() accepts everything despite if looking for something spesific

help

2 replies to this topic

#1 xilyflob

  • Members
  • 4 posts

Posted 08 October 2016 - 05:18 PM

Hello there everyone. The program I am having an issue with is designed to turn on/off a large group of reactors and turbines from the Big Reactors mod in sequence. Thanks to previous posts in the forum I was able to work out all of the actual errors, but now I am having an actual bug in it.

What is supposed to happen is if you type in "startup" it runs the startup sequence, and when you type in "shutdown" it does the shutdown sequence, and everything else tells you to try again. Right now though you could faceroll your keyboard and have it run the startup sequence. It wont run the elseif or else statements later in the program no matter what input.

Any help would be appreciated, and if you have any ideas for making the program shorter that would be nice too, I realize there is a lot of repetition.

Here is a pastebin http://pastebin.com/PbXPu9k1 and under the spoiler in the same code for completeness.


Spoiler


If the startup program for this computer or the other end of the rednet.send/receive and its startup are needed let me know. And thanks in advance.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,464 posts

Posted 08 October 2016 - 08:57 PM

if response == "Startup" or "startup" then

The above reads, 'If the variable "response" is equal to the string "Startup", OR the string "startup" is neither nil nor false, then'

You'd need to compare the variable to each of the values you want to test for. Or, since the two values are only different by capitalization, you could force the variable to lowercase and then just check it once:

if string.lower(response) == "startup" then


#3 xilyflob

  • Members
  • 4 posts

Posted 08 October 2016 - 09:06 PM

Ah ok, that makes sense. Forcing lowercase worked wonderfully as well. Much appreciated!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users