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

Don't even know where to begin at this point...

Started by Tassyr, 12 April 2015 - 12:08 AM
Tassyr #1
Posted 12 April 2015 - 02:08 AM
So I've got a project I've set myself that makes me realise just how little I remember of this system.

I've managed to set up Redstone In Motion so that a large gate mechanism moves back and forth. Fine, that was (I thought!) The hard part. So now I turn to computercraft…

My original intention was to use a Comptuercraft Advanced Monitor that has two buttons on it: "Open" and "Closed." Tap one, and it pulses the redstone circuit that opens the door enough times to get the job done. Touch the other, and- well, yeah, The opposite happens.

I know I need to get the bundled api, but I don't even remember where that IS any more. And I can't remember how the touchscreen works either.

Could anyone point me in the direction of the right help files, at least? Or perhaps fire a tutorial or hint my way…?



But the biggest stumbling block possible is one that I don't even know if it's possible. A friend told me one of those little pocket machines could be used to send a -remote- signal to the machine to make it open/close the gate from afar. Is that even possible? If so, where on earth would I look?
KingofGamesYami #2
Posted 12 April 2015 - 02:22 AM
Alright, so for bundled cable you want this, more specifically this

For touchscreen, you want to look at the monitor touch events.

(Wireless) Pocket Computers can send messages over rednet, or through the modem api directly.
Edited on 12 April 2015 - 12:23 AM
Tassyr #3
Posted 12 April 2015 - 02:28 AM
Alright, so for bundled cable you want this, more specifically this

For touchscreen, you want to look at the monitor touch events.

(Wireless) Pocket Computers can send messages over rednet, or through the modem api directly.

Hm. How easy is rednet to work, then? And thanks for the info!


Erm, question. I'm trying to poke around in monitor_touch and- what's the need for 'tostring?' and print? Why can't I somehow directly dump it to a variable?
Ignore that, I'm an idiot.
Edited on 12 April 2015 - 12:36 AM
KingofGamesYami #4
Posted 12 April 2015 - 02:40 AM
Rednet is pretty easy, basic explination:

Step 1: Open

rednet.open( "side_of_modem" )

Other stuff:

rednet.broadcast( "message" ) --#sends message to every computer with a modem
rednet.send( 1, "message" ) --#sends message to the computer with the id 1*
local id, message = rednet.receive( 5 ) --#waits for a message for 5 seconds, stores the id of the sender and the message.
--#if no time is specified, it'll wait forever

You can also take a look into rednet_message events if you want to run with other events.

You don't need to tostring, you can dump it into a variable. The example code does that because… idk why actually.

For example, this is perfectly acceptable:

while true do
  local event = {os.pullEvent()}
  if event[ 1 ] == "monitor_touch" then
    print( textutils.serialize( event ) )
  end
end

The reason for the prints is so people can see the outputs, it is an example after all.
Edited on 12 April 2015 - 12:41 AM
Lyqyd #5
Posted 12 April 2015 - 04:32 AM
Moved to Ask a Pro.
Tassyr #6
Posted 12 April 2015 - 05:41 AM
Rednet is pretty easy, basic explination:

Step 1: Open

rednet.open( "side_of_modem" )

Other stuff:

rednet.broadcast( "message" ) --#sends message to every computer with a modem
rednet.send( 1, "message" ) --#sends message to the computer with the id 1*
local id, message = rednet.receive( 5 ) --#waits for a message for 5 seconds, stores the id of the sender and the message.
--#if no time is specified, it'll wait forever

You can also take a look into rednet_message events if you want to run with other events.

You don't need to tostring, you can dump it into a variable. The example code does that because… idk why actually.

For example, this is perfectly acceptable:

while true do
  local event = {os.pullEvent()}
  if event[ 1 ] == "monitor_touch" then
	print( textutils.serialize( event ) )
  end
end

The reason for the prints is so people can see the outputs, it is an example after all.

Okay, so far so good- but how do I combine two events, then? In this case the monitor touch screen and wireless events?
flaghacker #7
Posted 12 April 2015 - 06:48 AM
Use os.pullEvent () in a loop:

while true do
  event, par1, par2 = os.pullEvent ()

  if event == "monitor_touch" then
    --handle touch screen, par1 is the x-coordinate and par2 the 6-coordinate
  elseif event == "rednet_message" then
    --handle rednet message, par1 is the sender's (') id and par2 is the message (as a string)
    --the pocked computer could e.g. send "open" or "close" to the gate computer.
  end
end

You might want to read the os.pullEvent documentation to see what other events exist and what their returned details are:
http://computercraft.info/wiki/Os.pullEvent
Edited on 12 April 2015 - 05:25 AM
Tassyr #8
Posted 12 April 2015 - 11:04 AM
Okay, so this is what I've got. For some reason the redstone bundles won't trigger. Any ideas?


--Attempt at Gate Control program--
yPos = 0
local monitor = peripheral.wrap("left")
monitor.clear()
monitor.setTextScale(1.5)
redstone.setBundledOutput("right",0)

while true do

monitor.setBackgroundColor(colors.black)
monitor.clear()

monitor.setTextColor(colors.black)
monitor.setBackgroundColor(colors.red)
monitor.setCursorPos(1,1)
monitor.write "	 "
monitor.setCursorPos(1,2)
monitor.write "OPEN "
monitor.setCursorPos(1,3)
monitor.write "	 "

monitor.setTextColor(colors.black)
monitor.setBackgroundColor(colors.green)
monitor.setCursorPos(1,6)
monitor.write "	 "
monitor.setCursorPos(1,7)
monitor.write "CLOSE"
monitor.setCursorPos(1,8)
monitor.write "	 "

event, side, xPos, yPos = os.pullEvent("monitor_touch")
if yPos < 5 then
monitor.setBackgroundColor(colors.blue)
monitor.clear()
monitor.setCursorPos (1,1)
monitor.write "	 "
sleep(1)
local i = 0
  repeat
  redstone.setBundledOutput("right",colors.white)
  sleep(1)
  redstone.setBundledOutput("right",0)
  sleep(1)
  i = i + 1
  until i == 16
end
if yPos > 6 then
monitor.setBackgroundColor(colors.blue)
monitor.clear()
monitor.setCursorPos (1,1)
monitor.write "	 "
sleep(1)
local i = 0
  repeat
  redstone.setBundledOutput("right",colors.black)
  sleep(1)
  redstone.setBundledOutput("right",0)
  sleep(1)
  i = i + 1
  until i == 16
end

end

http://pastebin.com/txW0Pfei for reference, the pastebin info.
Bomb Bloke #9
Posted 12 April 2015 - 12:29 PM
Mods and their versions matter a lot here. What version of ComputerCraft are you using? What sort of cable are you using, and what version of the mod it comes from are you using?
Tassyr #10
Posted 12 April 2015 - 01:42 PM
Mods and their versions matter a lot here. What version of ComputerCraft are you using? What sort of cable are you using, and what version of the mod it comes from are you using?

Everything that's included in the newest version of tekkit.
Bomb Bloke #11
Posted 12 April 2015 - 01:56 PM
I'm not terribly interested in looking that up, personally.
Tassyr #12
Posted 12 April 2015 - 02:15 PM
I'm not terribly interested in looking that up, personally.
Well sadly I'm on mobile until later so I can't check For a few hours
Edited on 12 April 2015 - 12:19 PM
Tassyr #13
Posted 12 April 2015 - 03:20 PM
Okay: Computercraft, 1.63. The wires are from ProjectRed:Transmission, Version 4.3.7.32
flaghacker #14
Posted 12 April 2015 - 06:07 PM
The computercraft bundled cable api isn't compatible with projectred atm, only minefactory reloaded cables work. There was a bit of a discussion about who should implement the projectred compatebility, cc or pr.
Edited on 12 April 2015 - 04:07 PM
HPWebcamAble #15
Posted 12 April 2015 - 06:08 PM
Here's a pastebin I have with the required versions of MFR and PR for CC 1.6 (You know, just in case):
http://pastebin.com/1XY12jQZ
Tassyr #16
Posted 12 April 2015 - 09:48 PM
The computercraft bundled cable api isn't compatible with projectred atm, only minefactory reloaded cables work. There was a bit of a discussion about who should implement the projectred compatebility, cc or pr.
Here's a pastebin I have with the required versions of MFR and PR for CC 1.6 (You know, just in case):
http://pastebin.com/1XY12jQZ

Wonderful- at least I know it isn't me screwing up. I don't suppose either of you'd know how to manually update this stuff, would ya?
flaghacker #17
Posted 12 April 2015 - 11:24 PM
If you are paying tekkit single player, you can just update the jar files in your tekkit instalation folder, in /packname/mods/

You can also switch to mfr cables if that mod is in your pack.
Bomb Bloke #18
Posted 12 April 2015 - 11:28 PM
Unfortunately, you can't update PR further without also upgrading your whole MineCraft install to 1.7.something. Likewise, best I can make out, MinefactoryReloaded 2.7.9 is the final version of MFR available for MC 1.6.4. HPWebcamAble, you might consider updating your paste to reflect that… You can't use those mods alongside CC 1.6 (or CC 1.63 for that matter), you'd need CC 1.64 or later. And that involves a MC version jump.

Unfortunately, the only way that I'm aware of to use bundled cables under MC 1.6.4 is to downgrade CC to 1.58 (or earlier), which should make it work with MFR's rednet cables. You may also need to downgrade MFR. I'm afraid doing this without starting a whole new world is likely to cause issues, so really you'd be better off jumping to a MC 1.7.10 pack.