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

Controling A Base

Started by WeaponMaster, 01 March 2014 - 01:07 PM
WeaponMaster #1
Posted 01 March 2014 - 02:07 PM
Greetings,
so I am building a huge underground base, around 10x10 chunks, on a server, and I have a couple of questions about computercraft, since I want to be able to control my base using it. I am OK using java, though pretty much a newbie to lua. Kindly help me to the extent of your capability.
1. Is it possible to make a Control Panel, using an advanced monitor, which can be clicked on to give certain outputs. EG- a map of the facility, where you can click on a gate on the map and it will open, and the gate icon will change colour. How can can you display this and how do you recognize a click?
2. Is it possible to make a computer interact with rednet cables from MineFactoryReloaded?
3. What is the alogrithm to determine signal range of a rednet modem? Do blocks interfere with range? or only rain?
4. Is there a page someone can link me to with all the programs and methods for reference?
5. What is peripheral wrapping?

I think that is it for now, Please assist, and thank you for your time.
Weapioneer
Edited on 01 March 2014 - 01:28 PM
unobtanium #2
Posted 01 March 2014 - 04:05 PM
Hello :)/>

To your questions:
1. Yes this is possible. However you would have to make the map on your own and only pixel and text can change their colors. The pixel size is fairly big so your map wont be very detailed at all. It would be better with your gate names and a "Open"/"Closed" Symbol behind that.
The os.pullEvent() returns a numerous amount of input, including the "monitor_touch" event. This can be used to identify the position of the pixel you clicked on.

2. They did in the past and i am to 90% sure they still do.

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.

4. http://computercraft.../wiki/Main_Page


5. http://computercraft...Peripheral_(API)
Interaction with the computer and another block.
Edited on 01 March 2014 - 03:07 PM
CometWolf #3
Posted 01 March 2014 - 04:15 PM
3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.
The max distance is at max world height, and at the bottom of the world it's like 64. Thunderstormes do still affect this, and will reduce it to 16 blocks bottom level. To avoid these issues, you could use wired modems.

5. peripheral.wrap() is a function that creates a table(array) of all the functions acessible to a particulair peripheral, and returns this. It is commonly used to name a peripheral for the rest of your code, since you can wrap it to a variable of your choosing, then call it's functions with variable.function()
WeaponMaster #4
Posted 01 March 2014 - 05:01 PM
Hello :)/>

To your questions:
1. Yes this is possible. However you would have to make the map on your own and only pixel and text can change their colors. The pixel size is fairly big so your map wont be very detailed at all. It would be better with your gate names and a "Open"/"Closed" Symbol behind that.
The os.pullEvent() returns a numerous amount of input, including the "monitor_touch" event. This can be used to identify the position of the pixel you clicked on.

2. They did in the past and i am to 90% sure they still do.

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.

4. http://computercraft.../wiki/Main_Page


5. http://computercraft...Peripheral_(API)
Interaction with the computer and another block.
ok, Thanks. I was planning to make the map pretty simple anyway. Do you know any tutorials for making a monitor map and menu easily?

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.
The max distance is at max world height, and at the bottom of the world it's like 64. Thunderstormes do still affect this, and will reduce it to 16 blocks bottom level. To avoid these issues, you could use wired modems.

5. peripheral.wrap() is a function that creates a table(array) of all the functions acessible to a particulair peripheral, and returns this. It is commonly used to name a peripheral for the rest of your code, since you can wrap it to a variable of your choosing, then call it's functions with variable.function()

I plan to build a base underground, and with the monitor at roughly 32 blocks Y. I suppose this won't give me enough range for a base roughly 12x12 chunks, = around 200 blocks. Is it possible to have it send messages to a computer at 250 Y for it to be relayed around? Using wired modems is an option, but can multiple devices and computers be connected to the same cable coming from a main computer over long distance? I plan to control computers on the far ends of my base using that(the far off computers are for doors). Also, is there anyway to 'encrypt' a message so that others cannot send a false message to open my doors for them.

Thanks a lot,
Weapioneer
unobtanium #5
Posted 01 March 2014 - 05:19 PM
Ah dang, i did not knew that the height was taking such a huge part in the range of rednet :(/>

Sorry, i am not into monitors anymore too much. I did a program over a big monitor a while ago using the redirect function and stuff.
So maybe check that out over here for the code and here for the post.

Your cable connects a whole network and it doesnt matter how many computer are connected to it. They all just have to be connected on the same cable like the main computer does. The chuncks have to be loaded to communicate otherwise the computer/turtle will shutdown.

Well if you are using the wired modems it is allready safer against attackers then using the wireless modems. And players will allways have the ability to look into the source code of your program to figure it out and send their own message.
CometWolf #6
Posted 01 March 2014 - 05:47 PM
The relay computer would be a possible solution yes, but using wires is probably a lot easier since they can connect the peripherals directly to the computer, while the wireless ones will need a seperate computer with a wireless modem of it's own connected to it aswell as being next to the peripheral. All the points Unobtainum made encourage their usage aswell.
Bomb Bloke #7
Posted 02 March 2014 - 03:17 AM
A note re wireless signals, when dealing with two-way communications only the range of the highest computer counts. That is to say, so long as one computer is in range of the other, both can send messages either way. A server placed near world-height can hence be coded to act as a relay system between all computers in its range.

When dealing with peripherals, wired connections are generally easier given that wireless modems only work with computers/turtles.

Encryption is perfectly possible, but entirely up to you to implement. However, if you decide to hard-code your keys into your computers, then anyone with direct access to those computers could get them, and it's a bit harder to lock down a server room in MineCraft then it is in real life.
skwerlman #8
Posted 02 March 2014 - 11:01 AM
As far as encryption, you could always go with Immibis' peripherals. (link)
His cryptographic accelerator lets you access any algorithm in the Bouncy Castle Java library. (link)
Plus there are some other really cool blocks in there.

Also, I think I can write a code that can detect unauthorized computers on your cable network. I'll post it in the Programs section when its done, and link to it from here.
WeaponMaster #9
Posted 02 March 2014 - 03:37 PM
Ok, I think i will just go for wired, since I already plan to have tunnels for eu and mj cables and such. Also, just seems simpler to manage and harder to hack. What happens if i try to send a message to a computer which is in a chunk which is just out of the player's chunkload range?
Also, do cables have a limit? or can i just keep it going for huge distances? The distance between my server and door controlling computers is around 80 blocks.
Edited on 02 March 2014 - 02:40 PM
CometWolf #10
Posted 02 March 2014 - 07:22 PM
I dunno about the distance, but both computers have to be loaded for them to be able to talk to each other, obviously. 80 blocks should be fine though, as it's not much really.
WeaponMaster #11
Posted 06 March 2014 - 05:53 AM
So I made a simple bit of code for a door which uses a CC Peripherals Player Detector to open and close a door when the player detector is right clicked. The monitor will be underground, with only the player detector accessable. How good is my code? any improvements anyone can suggest? And how can I change it so that it will open when either a modem on the bottom receives a message or clicked by me? And how do I find the rednet ID of a particular computer?

Thanks a lot,
Weapioneer



os.pullEvent = os.pullEventRaw
local u = "top"
while true do
    event, playerName = os.pullEvent("player")
    if playerName == "WeaponGuy117" then   
        print("Hello, " ..playerName)   
        redstone.setOutput(u, true)   
        sleep(10)   
        redstone.setOutput(u, false)   
        os.reboot()
    else   
        print("Access Denied")   
        sleep(10)  
   	 os.reboot()
end
end
CometWolf #12
Posted 06 March 2014 - 07:38 AM

os.pullEvent = os.pullEventRaw -- ditch this
local u = "top"
while true do
  event, playerName = os.pullEvent("player") -- change this to raw and don't use a filter here
  if event == "player" then
    if playerName == "WeaponGuy117" then   
      print("Hello, " ..playerName)   
      redstone.setOutput(u, true)   
      sleep(10)   
      redstone.setOutput(u, false)   
      os.reboot() -- ditch this too
    else   
      print("Access Denied")   
      sleep(10)  
      os.reboot() --ditch this
    end
  elseif event == "rednet_message" then
    --rednet code here
  end
end
You might want to restructure the pullEvent variables to deal with the ones returned by rednet. To get the rednet id do os.getComputerID().
DannySMc #13
Posted 06 March 2014 - 09:40 AM
Hello :)/>

To your questions:
1. Yes this is possible. However you would have to make the map on your own and only pixel and text can change their colors. The pixel size is fairly big so your map wont be very detailed at all. It would be better with your gate names and a "Open"/"Closed" Symbol behind that.
The os.pullEvent() returns a numerous amount of input, including the "monitor_touch" event. This can be used to identify the position of the pixel you clicked on.

2. They did in the past and i am to 90% sure they still do.

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.

4. http://computercraft.../wiki/Main_Page

5. http://computercraft...Peripheral_(API)
Interaction with the computer and another block.
ok, Thanks. I was planning to make the map pretty simple anyway. Do you know any tutorials for making a monitor map and menu easily?

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.
The max distance is at max world height, and at the bottom of the world it's like 64. Thunderstormes do still affect this, and will reduce it to 16 blocks bottom level. To avoid these issues, you could use wired modems.

5. peripheral.wrap() is a function that creates a table(array) of all the functions acessible to a particulair peripheral, and returns this. It is commonly used to name a peripheral for the rest of your code, since you can wrap it to a variable of your choosing, then call it's functions with variable.function()

I plan to build a base underground, and with the monitor at roughly 32 blocks Y. I suppose this won't give me enough range for a base roughly 12x12 chunks, = around 200 blocks. Is it possible to have it send messages to a computer at 250 Y for it to be relayed around? Using wired modems is an option, but can multiple devices and computers be connected to the same cable coming from a main computer over long distance? I plan to control computers on the far ends of my base using that(the far off computers are for doors). Also, is there anyway to 'encrypt' a message so that others cannot send a false message to open my doors for them.

Thanks a lot,
Weapioneer

Yes this is possible would mean you would need to create some kind of protocol on how you will transmit data. Also taking into account that you will need to make sure all the relay computers don't form a square so you do not keep sending it around and around, lagging the computer and the serve(s). This protocol would have to include: ID to receive and the message. Using this you can make a simple protocol which will send the ID it needs to be sent to, and then sends the data after, you can also use the protocol to check it's own ID to the ID the message needs to reach. I have made this before for my own server. If you want I don't mind coding the protocol and the relay programs for you? Just email me or message me on here? (danny.smc95@gmail.com)
WeaponMaster #14
Posted 06 March 2014 - 01:55 PM
Hello :)/>

To your questions:
1. Yes this is possible. However you would have to make the map on your own and only pixel and text can change their colors. The pixel size is fairly big so your map wont be very detailed at all. It would be better with your gate names and a "Open"/"Closed" Symbol behind that.
The os.pullEvent() returns a numerous amount of input, including the "monitor_touch" event. This can be used to identify the position of the pixel you clicked on.

2. They did in the past and i am to 90% sure they still do.

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.

4. http://computercraft.../wiki/Main_Page

5. http://computercraft...Peripheral_(API)
Interaction with the computer and another block.
ok, Thanks. I was planning to make the map pretty simple anyway. Do you know any tutorials for making a monitor map and menu easily?

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.
The max distance is at max world height, and at the bottom of the world it's like 64. Thunderstormes do still affect this, and will reduce it to 16 blocks bottom level. To avoid these issues, you could use wired modems.

5. peripheral.wrap() is a function that creates a table(array) of all the functions acessible to a particulair peripheral, and returns this. It is commonly used to name a peripheral for the rest of your code, since you can wrap it to a variable of your choosing, then call it's functions with variable.function()

I plan to build a base underground, and with the monitor at roughly 32 blocks Y. I suppose this won't give me enough range for a base roughly 12x12 chunks, = around 200 blocks. Is it possible to have it send messages to a computer at 250 Y for it to be relayed around? Using wired modems is an option, but can multiple devices and computers be connected to the same cable coming from a main computer over long distance? I plan to control computers on the far ends of my base using that(the far off computers are for doors). Also, is there anyway to 'encrypt' a message so that others cannot send a false message to open my doors for them.

Thanks a lot,
Weapioneer

Yes this is possible would mean you would need to create some kind of protocol on how you will transmit data. Also taking into account that you will need to make sure all the relay computers don't form a square so you do not keep sending it around and around, lagging the computer and the serve(s). This protocol would have to include: ID to receive and the message. Using this you can make a simple protocol which will send the ID it needs to be sent to, and then sends the data after, you can also use the protocol to check it's own ID to the ID the message needs to reach. I have made this before for my own server. If you want I don't mind coding the protocol and the relay programs for you? Just email me or message me on here?
I was planning to use a satellite relay station, but i think just going with networking cable will be better. Could you help me modify the program so that either clicking on the player detector or receiving the message "open" will make it output redstone?

Thanks
WeaponMaster #15
Posted 09 March 2014 - 12:05 AM

os.pullEvent = os.pullEventRaw

rednet.open("bottom")

local u = "right"

while true do

 
    event, ev1, ev2, ev3, ev4 = os.pullEvent()

 
    if (ev1 == "WeaponGuy117") then

    
        redstone.setOutput(u, true)

    
        sleep(10)

    
        redstone.setOutput(u, false)

    
        os.reboot()


    elseif ev4 == "open" then

        redstone.setOutput(u, true)

        os.pullEvent()

        redstone.setOutput(u, false)


    elseif ev4 == "close" then

        redstone.setOutput(u, false)

    end

os.reboot()

end
 
Ok, so I tried to make my code a bit better so i can control it via networking cable or by clicking on the player detector. The part about it which is triggered by the playerdetector still works, but it does not respond to me sending messages to it from another computer.
Can someone help me fix my code?

Thank you,
Weapioneer
CometWolf #16
Posted 09 March 2014 - 12:13 AM
The message from rednet in your case would be the variable ev2, not ev4.
WeaponMaster #17
Posted 09 March 2014 - 01:17 AM
The message from rednet in your case would be the variable ev2, not ev4.
well, on the modem_message page, http://computercraft.info/wiki/Modem_message_%28event%29, it says that the 4th returned value is the message, is it really the second?
Thanks,
Weapioneer
CometWolf #18
Posted 09 March 2014 - 01:36 AM

rednet.open("bottom")
You're using rednet here, not modem. They're not the same, although i suppose you would get both events. What does the sender use to send?
WeaponMaster #19
Posted 09 March 2014 - 06:00 AM

rednet.open("bottom")
You're using rednet here, not modem. They're not the same, although i suppose you would get both events. What does the sender use to send?
rednet.send(). I really haven't used rednet or lua with a lot of depth, so do you know a good example or method to easily transmit to computers? i could use redstone.getInput() along with wireless redstone, but it seems better to use networking and modems instead.
CometWolf #20
Posted 09 March 2014 - 10:52 AM
I've actually never tried to communicate along a wired network, so idk how that works. But generally the easiest way would just be using rednet.open and then rednet.broadcast, or rednet.send if you know the id of the receiver.
twormtwo #21
Posted 09 March 2014 - 04:40 PM
I've actually never tried to communicate along a wired network, so idk how that works. But generally the easiest way would just be using rednet.open and then rednet.broadcast, or rednet.send if you know the id of the receiver.
I've played around with wired networks, they seem to broadcast the information to all the computers connected along the wire, but because rednet opens a channel with the computer ID, it will only show on the computer with the correct ID when using rednet.send() and all the computers along the line with rednet.broadcast()
I used a computer along the line to send to the computers in the picture via rednet signals. I executed rednet.broadcast("hello") rednet.send(27, "hello") rednet.send(20, "hello") rednet.send(21, "hello") on another in line computer and the events were written to the screens.
Spoiler
OReezy #22
Posted 10 March 2014 - 04:43 AM
ModemAPI

You wrap the modem as a peripheral and use open(channel) to listen on a channel, and transmit(channel, replyChannel, message) to send messages on that channel.

local modem = peripheral.wrap("side")
modem.open(12) --opens channel 12
modem.transmit(20, 5, "hello") -- sends on channel 20, with a reply channel 5, and the message 'hello'

To catch messages you use os.pullEvent() which gives you:
  1. event type (modem_message)
  2. side your modem is on
  3. channel
  4. reply channel
  5. message
  6. distance
Edited on 10 March 2014 - 03:47 AM
skwerlman #23
Posted 10 March 2014 - 04:02 PM
Wired rednet is the same as wireless rednet.
DannySMc #24
Posted 14 March 2014 - 12:49 PM
Hello :)/>

To your questions:
1. Yes this is possible. However you would have to make the map on your own and only pixel and text can change their colors. The pixel size is fairly big so your map wont be very detailed at all. It would be better with your gate names and a "Open"/"Closed" Symbol behind that.
The os.pullEvent() returns a numerous amount of input, including the "monitor_touch" event. This can be used to identify the position of the pixel you clicked on.

2. They did in the past and i am to 90% sure they still do.

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.

4. http://computercraft.../wiki/Main_Page

5. http://computercraft...Peripheral_(API)
Interaction with the computer and another block.
ok, Thanks. I was planning to make the map pretty simple anyway. Do you know any tutorials for making a monitor map and menu easily?

3. The maximal distance is 384 blocks. I dont think rain or blocks are effecting this anymore.
The max distance is at max world height, and at the bottom of the world it's like 64. Thunderstormes do still affect this, and will reduce it to 16 blocks bottom level. To avoid these issues, you could use wired modems.

5. peripheral.wrap() is a function that creates a table(array) of all the functions acessible to a particulair peripheral, and returns this. It is commonly used to name a peripheral for the rest of your code, since you can wrap it to a variable of your choosing, then call it's functions with variable.function()

I plan to build a base underground, and with the monitor at roughly 32 blocks Y. I suppose this won't give me enough range for a base roughly 12x12 chunks, = around 200 blocks. Is it possible to have it send messages to a computer at 250 Y for it to be relayed around? Using wired modems is an option, but can multiple devices and computers be connected to the same cable coming from a main computer over long distance? I plan to control computers on the far ends of my base using that(the far off computers are for doors). Also, is there anyway to 'encrypt' a message so that others cannot send a false message to open my doors for them.

Thanks a lot,
Weapioneer

Yes this is possible would mean you would need to create some kind of protocol on how you will transmit data. Also taking into account that you will need to make sure all the relay computers don't form a square so you do not keep sending it around and around, lagging the computer and the serve(s). This protocol would have to include: ID to receive and the message. Using this you can make a simple protocol which will send the ID it needs to be sent to, and then sends the data after, you can also use the protocol to check it's own ID to the ID the message needs to reach. I have made this before for my own server. If you want I don't mind coding the protocol and the relay programs for you? Just email me or message me on here?
I was planning to use a satellite relay station, but i think just going with networking cable will be better. Could you help me modify the program so that either clicking on the player detector or receiving the message "open" will make it output redstone?

Thanks

Yeah I can do this, tell me when you're free I shall get you on my server, or on yours and you can skype me, and we can talk about what you need, cause I am not completely sure what you are looking for but I kind of understand.