SHOW:
         |
         |
         - or go back to the newest paste.    
    | 1 | local tArg = { ... }
 | |
| 2 | ||
| 3 | --variables  | |
| 4 | local rSide = "bottom"  | |
| 5 | local rInput = "not set"  | |
| 6 | local rState = "off"  | |
| 7 | ||
| 8 | --predeclare  | |
| 9 | local printUsage  | |
| 10 | local getState  | |
| 11 | ||
| 12 | --functions--  | |
| 13 | function getState()  | |
| 14 | if redstone.getOutput(rSide,false) then  | |
| 15 | rState = "Spawner Active."  | |
| 16 | return  | |
| 17 | elseif redstone.getOutput(rSide,true) then  | |
| 18 | rState = "Spawner Inactive."  | |
| 19 | return  | |
| 20 | else  | |
| 21 | print( "Redstone GetState Error." )  | |
| 22 | return  | |
| 23 | end  | |
| 24 | end  | |
| 25 | ||
| 26 | function printUsage()  | |
| 27 | print( "Usage: spawner <on/off/current>" )  | |
| 28 | return  | |
| 29 | end  | |
| 30 | ||
| 31 | local rInput = tArg[1]  | |
| 32 | ||
| 33 | --start--  | |
| 34 | if #tArg <1 then  | |
| 35 | printUsage()  | |
| 36 | return  | |
| 37 | elseif rInput == "on" then  | |
| 38 | redstone.setOutput(rSide,false)  | |
| 39 | print( "Spawner now active." )  | |
| 40 | return  | |
| 41 | elseif rInput == "off" then  | |
| 42 | redstone.setOutput(rSide,true)  | |
| 43 | print( "Spawner now inactive." )  | |
| 44 | return  | |
| 45 | elseif rInput == "current" then  | |
| 46 | getState()  | |
| 47 | print( rState )  | |
| 48 | return  | |
| 49 | else  | |
| 50 |   print("Error.")
 | |
| 51 | printUsage()  | |
| 52 | end  |