- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
TheReduxPL
-
Content Count
3 -
Joined
-
Last visited
Posts posted by TheReduxPL
-
-
you should not do this though io.read (), build the string yourself through computer.pullSignal, that way you cant bypass by pressing ctrl-alt-c either.
How do I use this? I replaced io.read() to computer.pullSignal() and now my computer got in a reboot loop >.<
-
Hello!
Thanks to the guys from IRC I managed to make a script which asks for password. If the password is right, it sends a redstone signal for 3 seconds. If it's wrong, it asks again. Now I want the script to be protected against using Ctrl+C to terminate it. This is what we managed to do:
<old, broken code was here>
After trying to implement the "anti terminating thingy", this script is not working as fully expected.
1. When I enter a wrong password, it says "Invalid!" and terminates itself. I would like it to ask again instead.
2. When I enter a correct password, it says "Valid!", sends a redstone signal for 3 seconds, then asks for a password again. Exactly what I would like it to be. Except the script terminates itself when the entered password is wrong, same as with first point.
3. Script still can be terminated.
I just started messing with LUA. Thanks for any advance!
EDIT: After messing with the script for another few hours. I made it to work! It's my first script that actually works.
local component = require("component") local computer = require("computer") local filesystem = require("filesystem") local event = require("event") local gpu = component.gpu local io = require("io") local os = require("os") local rs = component.redstone local sides = require("sides") local term = require("term") term.clear() gpu.setResolution(37, 5) -- makes the resolution smaller, can be safely removed rs.setOutput(sides.right, 0) -- makes sure the redstone signal is off; change "right" to the direction you want to emit redstone signal from print("A room full of diamonds - access restricted") -- replace the text in quotas with anything you want term.write("Password: ") password = io.read() if password == "POTATOE" then -- replace POTATOE with your password print("ACCESS GRANTED!") rs.setOutput(sides.right, 5) -- change "right" to the direction you want to emit redstone signal from gpu.setResolution(50, 16) -- bring the resolution back to normal; if you use a bigger screen, you might want to change it os.sleep(1) term.clear() os.exit() else print("ACCESS DENIED!") computer.shutdown(true) end
To make it safe from terminating, it needs to be saved as "autorun.lua" on any drive. Each time someone tries to terminate it, computer restarts and the scripts is being launched again.
When someone enters a wrong password, computer restarts and the script is being launched again.
When someone enters a right password, the redstone signal is being emited (for a door for example), then the script shuts down . It can be easily launched without digging through directories just by rebooting a computer. Redstone signal is turned off after relaunching the script.
Anyway, thanks for guys from IRC for help!
Prevent script termination
in Programming
Posted
I'm not fluent with this language so forgive me Thanks for the example but I resolved the problem in a bit different way.