Checking numbers on signs?

Discussion in 'Plugin Development' started by 9903286, Jan 30, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    9903286

    How do i for example, if the bottom line of the sign is 3, how do i check if it's over 0 or not.
    Like:
    Code:
    if(signText[3] <= 1) {
        //TROLOLOL
    }
     
  2. Offline

    TheFieldZy

    Code:java
    1.  
    2. String lastLine = sign.getText(4); //You will need a sign reference variable to the Sign you are getting
    3. int lastLineNum = Integer.parseInt(lastLine);
    4. if (lastLineNum <= 1) {
    5. //whatever you planned to do
    6. }
     
  3. shouldn't it be >= 1, because you said over 0?
     
  4. Offline

    desht

    Yes, but you should really be catching (and cleanly handling) NumberFormatException from Integer.parseInt() or be prepared for a bunch of ugly backtraces in your server log...
     
  5. what if you simply use "num > 0"? You can almost "talk" to java.^^
     
  6. Offline

    TheFieldZy

    True, I just typed this up real quick.
     
Thread Status:
Not open for further replies.

Share This Page