This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
NullSchritt's profile picture

Executing command as operator, or providing special permission to computers?

Started by NullSchritt, 15 May 2013 - 01:00 AM
NullSchritt #1
Posted 15 May 2013 - 03:00 AM
Hello, on my server I am using the stargates plugin, and I want to disable the dialing of gates by commands for regular players, so that they have to provide the required materials to create the address.

However at public gates I would like to offer dialing computers, that will load from a floppy disk, and get the name of the computer it is on (which will match the gate origin name), and then execute the dial command to connect the two gates.

My question is, is there a way to execute an operator only command with computercraft, or a way to make a special permission class specifically for computer craft, and if so, what would an example code/config look like?

Thanks!
darkrising #2
Posted 15 May 2013 - 09:50 AM
Yes, use command blocks and wrap it as a peripheral (Also needs to be enabled in the configs)

Make sure you hide the command block too, they can be quite dangerous!

I would give an example but I can't remember the functions off the top of my head for command blocks.

Edit: http://computercraft.info/wiki/Command_Block_(API)
NullSchritt #3
Posted 15 May 2013 - 09:38 PM
Thanks for the link. Just a quick question though, wouldn't anyone with access to a terminal be able to hack it? (unless I somehow made it so it was impossible to edit the program)

Is there a way I can prevent the files on a pc from being edited without a password? To prevent users from hijacking the command block.
PixelToast #4
Posted 15 May 2013 - 09:50 PM
bedrock / permissions and os.pullEvent=os.pullEventRaw
NullSchritt #5
Posted 15 May 2013 - 09:57 PM
bedrock / permissions and os.pullEvent=os.pullEventRaw

I meant from hacking the terminal, I just wanna know how to prevent them from exiting the default program and being able to edit the code, to write things to the command block they shouldn't.
PixelToast #6
Posted 15 May 2013 - 10:00 PM
os.pullEvent=os.pullEventRaw
NullSchritt #7
Posted 15 May 2013 - 10:05 PM
os.pullEvent=os.pullEventRaw
Thank you, I appreciate your help, but I am too much of a noob to know where to put this. At the top line of my code?
Spongy141 #8
Posted 15 May 2013 - 10:13 PM
os.pullEvent=os.pullEventRaw
Thank you, I appreciate your help, but I am too much of a noob to know where to put this. At the top line of my code?
It doesn't really matter, well it does, like if you do not want it to be hackable after 3 seconds then do sleep(3) then os.pullEvent = os.pullEventRaw …its safer to have it at the top of your code though.
NullSchritt #9
Posted 16 May 2013 - 02:57 AM
Hello, thanks for all the help so far, I've started to get together a basic program to do what I want. I seem to have stumbled onto one more problem.

When I call the command it will return 8-10 lines of text

ex:
Chevron 1 Engaged
Chevron 2 Engaged
Chevron 3 Engaged
Chevron 4 Engaged
Chevron 5 Engaged
Chevron 6 Engaged
Chevron 7 Engaged
Gate Connection [Active/Failed] (reason)

This text is normally sent to the chat of the player who calls the command, is there any way to capture this text(to show on a monitor)?
PixelToast #10
Posted 16 May 2013 - 10:07 AM
term.redirect(peripheral.wrap("side"))
then
term.restore()
afterwards
D3matt #11
Posted 16 May 2013 - 01:29 PM
Yes, use command blocks and wrap it as a peripheral (Also needs to be enabled in the configs)

Make sure you hide the command block too, they can be quite dangerous!

I would give an example but I can't remember the functions off the top of my head for command blocks.

Edit: http://computercraft...and_Block_(API)
Non ops cannot edit command blocks, so there's no need to worry about that.
darkrising #12
Posted 16 May 2013 - 03:38 PM
Yes, use command blocks and wrap it as a peripheral (Also needs to be enabled in the configs)

Make sure you hide the command block too, they can be quite dangerous!

I would give an example but I can't remember the functions off the top of my head for command blocks.

Edit: http://computercraft...and_Block_(API)
Non ops cannot edit command blocks, so there's no need to worry about that.

No but the computer can
NullSchritt #13
Posted 16 May 2013 - 05:32 PM
term.redirect(peripheral.wrap("side"))
then
term.restore()
afterwards
Thanks, works like a charm, however, I was wondering if there would be a way to process the data as it comes in, for example, checking if each line contains a certain text, for example waiting for the command to either say an error has occured, OR waiting for it to say the gate has disconnected, before allowing the user to input a new address?