Jump to content




[CC 1.46 | MC 1.4.2] Command Block Peripheral 0.0.3


35 replies to this topic

#1 crazyputje

  • New Members
  • 7 posts

Posted 28 October 2012 - 04:45 PM

Command Block Peripheral 0.0.3



This add-on will allow vanilla command blocks to interact with ComputerCraft computers.
The command block will work the same as any other peripheral.



Methods:

cmd.setCommand(String newcmd) (sets the command on the command block)
cmd.runCommand() (runs the command that is in the command block)
cmd.runCommand(String cmd) (runs the given command)
cmd.getPlayers(String targetselectors) (returns a string that contains username(s))

How target selectors work: https://gist.github.com/3736487

examples:
cmd = peripheral.wrap("left")
mon = peripheral.wrap("right")
mon.clear()
mon.write("Hello, "..cmd.getPlayers("@p").."!")
cmd = peripheral.wrap("left")
cmd.setCommand("Time set day")
cmd.runCommand()
cmd = peripheral.wrap("left")
cmd.runCommand("give @r 137")

Download:
commandblockperipheral_0.0.3 (universal)

Requirements:
- ComputerCraft 1.46
- Minecraft Forge (compiled with Forge 6.0.1.341)

Installation:
Download the zip file, put it in your mods folder.

Extra information:
- This mod can be used as a serverside mod and doesn't require you to have the client installed.
- This mod doesn't edit baseclasses nor does it use a block ID.

#2 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 28 October 2012 - 05:19 PM

Nice work :)/> I really need to try this when i got time :D/>

#3 BigSHinyToys

  • Members
  • 1,001 posts

Posted 28 October 2012 - 05:39 PM

That is one hell of a first post. Downloading ...

#4 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 28 October 2012 - 07:43 PM

How did you manage this? I'm guessing reflection to add the peripheral?

#5 crazyputje

  • New Members
  • 7 posts

Posted 30 October 2012 - 07:54 PM

View PostCloudy, on 28 October 2012 - 07:43 PM, said:

How did you manage this? I'm guessing reflection to add the peripheral?

I used reflection to manipulate the blocklist.First, the vanilla cmdblock is removed from the list, after that I add a new cmdblock with the same id which extends the vanilla cmdblock. That block has a different tileentity that again extends the vanilla cmdblock tileenty. Just implement peripheral and done...

I'm currently looking for a way to add the peripheral without manipulating the blocklist

#6 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 30 October 2012 - 08:04 PM

That's quite a hack, but neat.

I plan on work on letting you add a peripheral to any arbitrary tile entity, and then using that system to add native CC command block support (already planned if you look in suggestions forum, so not stealing your idea :P/>).

#7 crazyputje

  • New Members
  • 7 posts

Posted 30 October 2012 - 08:43 PM

View PostCloudy, on 30 October 2012 - 08:04 PM, said:

That's quite a hack, but neat.

I plan on work on letting you add a peripheral to any arbitrary tile entity, and then using that system to add native CC command block support (already planned if you look in suggestions forum, so not stealing your idea :P/>).

Nice, looking forward to it :D/> And I had no idea it was already suggested, I thought I was original :P/>

#8 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 30 October 2012 - 10:18 PM

View Postcrazyputje, on 30 October 2012 - 08:43 PM, said:

View PostCloudy, on 30 October 2012 - 08:04 PM, said:

That's quite a hack, but neat.

I plan on work on letting you add a peripheral to any arbitrary tile entity, and then using that system to add native CC command block support (already planned if you look in suggestions forum, so not stealing your idea :P/>).

Nice, looking forward to it :D/> And I had no idea it was already suggested, I thought I was original :P/>

Cloudy said he was going to do it, but it didn't happend, even after i slapped him 9001 times :/

Been playing with it now though :D/> nice work :)/>

#9 dw28394

  • Members
  • 84 posts

Posted 31 October 2012 - 02:03 PM

Wow, this seems incredible. I had no idea computers had the power to hook up with cmd blocks even with a peripheral. Amazing.

#10 dw28394

  • Members
  • 84 posts

Posted 31 October 2012 - 02:27 PM

I just tried it out and every thing I try(I tested your examples also) just returns:
(name):(line): attempt to index ? (a nil value)
This is the program:
cmd = peripheral.wrap("right")
cmd.setCommand("time set night")
cmd.runCommand()


#11 crazyputje

  • New Members
  • 7 posts

Posted 31 October 2012 - 06:52 PM

View PostRangicus, on 31 October 2012 - 02:27 PM, said:

I just tried it out and every thing I try(I tested your examples also) just returns:
(name):(line): attempt to index ? (a nil value)
This is the program:
cmd = peripheral.wrap("right")
cmd.setCommand("time set night")
cmd.runCommand()

hmm, I can only think of two things: you installed it wrong or there is no command block on the right

#12 dw28394

  • Members
  • 84 posts

Posted 31 October 2012 - 07:55 PM

View Postcrazyputje, on 31 October 2012 - 06:52 PM, said:

View PostRangicus, on 31 October 2012 - 02:27 PM, said:

I just tried it out and every thing I try(I tested your examples also) just returns:
(name):(line): attempt to index ? (a nil value)
This is the program:
cmd = peripheral.wrap("right")
cmd.setCommand("time set night")
cmd.runCommand()

hmm, I can only think of two things: you installed it wrong or there is no command block on the right
All you need to do is put the .zip in your mods folder it would be hard to install it wrong.

#13 crazyputje

  • New Members
  • 7 posts

Posted 31 October 2012 - 08:35 PM

View PostRangicus, on 31 October 2012 - 07:55 PM, said:

View Postcrazyputje, on 31 October 2012 - 06:52 PM, said:

View PostRangicus, on 31 October 2012 - 02:27 PM, said:

I just tried it out and every thing I try(I tested your examples also) just returns:
(name):(line): attempt to index ? (a nil value)
This is the program:
cmd = peripheral.wrap("right")
cmd.setCommand("time set night")
cmd.runCommand()

hmm, I can only think of two things: you installed it wrong or there is no command block on the right
All you need to do is put the .zip in your mods folder it would be hard to install it wrong.

I know but it wouldn't surprise me if someone failed to install it. The world is filled with stupid people :P/>

edit: I will check if there is something wrong on my end

#14 crazyputje

  • New Members
  • 7 posts

Posted 31 October 2012 - 11:40 PM

Updated it to 0.0.2

Instead of hacking into the blockslist I now hack into the TileEntityList. :P/>
Also allot of code clean up

#15 chalenged

  • New Members
  • 11 posts

Posted 03 November 2012 - 01:05 PM

I have a security concern with this. Is anything stopping someone without mod status from placing a computer on a command block placed by an admin and using that to execute admin commands such as give?

#16 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 03 November 2012 - 03:46 PM

View Postchalenged, on 03 November 2012 - 01:05 PM, said:

I have a security concern with this. Is anything stopping someone without mod status from placing a computer on a command block placed by an admin and using that to execute admin commands such as give?

Nope - but there is also nothing stopping a non op player from accessing a placed command block themselves.

#17 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 04 November 2012 - 12:40 AM

I thought you needed to be in creative mode to edit a cmd block? unless i missread the wiki :D/>

#18 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 04 November 2012 - 11:38 PM

I just re-read and this does indeed appear to be the case. A solution though: keep the command block and associated computer buried under bedrock.

#19 luacs1998

  • New Members
  • 1 posts

Posted 08 November 2012 - 06:18 PM

Or just password protect the computer, and only ops know the password.

#20 overfritz

  • Members
  • 65 posts

Posted 13 November 2012 - 12:15 PM

View Postluacs1998, on 08 November 2012 - 06:18 PM, said:

Or just password protect the computer, and only ops know the password.
That's what you do. Pass-Protect the computer (either using Immibis' peripherals, or using a program that uses Floppy's.)

Will get this and try it out.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users