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

[Requesting Assist]RedNet to Screens, Random Selector, Networking

Started by DigiZA, 05 December 2014 - 05:58 AM
DigiZA #1
Posted 05 December 2014 - 06:58 AM
Greetings one and all,

Im hoping that I can possibly find some help, im doing something that is WAY over my head, I'm going through Youtube videos, reading up on lua, and doing everything I can to do this project of mine on my own, but with work and this time of year im having less and less time to do so.

Anyways What I am doing is a huge multi-part program, the Idea in my head sounds epic if i get it right but i think im seriously asking too much of poor lua and computer craft.

The setup firstly, is I have a "operator booth" that has a ADV. Computer, and screen with various buttons for various functions.
This is using Rednet cables to link to other machines, and various other screens.
i) General Display Screen
ii) Computers around a area (20x20), linked to a command block, and a Auto-Spawner

I have done a little Button API, sliced various things ive learnt from various vids, and that outputs to the operators monitor.
I have created a program called Mix(v) that will execute a sound execution command on the command block allowing me to play stored OGG files that were converted from mp3.
I have a program called Mobber(n), that places a random mob type into a Auto-Spawner
Ill PasteBin the codes this evening if they needed for anything

Basically I'm still trying to do the following things:

1) Send command along single Rednet cable (bottom) and all computers linked to it execute program Mix, and Mobber as needed.
2) Send a command along a Rednet cable (back) to a monitor and Display images (dont even know if can be done without another computer havent had a chance to look into it yet)
i) This has a part 2, Want to have a Random selector, like Flash images and randomly stop at one, and store its code on the executing system. This code ill be using as a parameter for the Mix and Mobber programs on other terminals.

If its needed or helps, this is running on my server (FTB - direwolf20 1.7 v1.0.2) - testing everything in single player at moment.
Bomb Bloke #2
Posted 05 December 2014 - 11:33 AM
1) Send command along single Rednet cable (bottom) and all computers linked to it execute program Mix, and Mobber as needed.

If you're using MineCraft 1.7.10 (or any release of ComputerCraft after 1.58, for that matter), then as far as I'm aware, bundled cables - such as Rednet cables - aren't going to work with CC. There are "partial" exceptions to this, but I'm fairly certain MFR isn't one of them.

But a basic script that looks for a redstone signal might look like this:

while true do  -- Start a loop that repeats indefinitely.
  os.pullEvent("redstone")  -- Wait for a change in redstone input.

  if rs.getInput("bottom") then  -- If a redstone input is active below the system,
	shell.run("mix")  -- Run a script.
  end
end

2) Send a command along a Rednet cable (back) to a monitor and Display images (dont even know if can be done without another computer havent had a chance to look into it yet)

This cannot be done using bundled cables unless another computer is involved (regardless of your mod versions). However, ComputerCraft's own network cables allow computers to control peripherals (such as monitors) remotely - see here.
Edited on 05 December 2014 - 10:33 AM
Agent Silence #3
Posted 05 December 2014 - 05:08 PM
-snip-
I think he meant Modem Cable, not Rednet Cable
Edited on 05 December 2014 - 04:08 PM
DigiZA #4
Posted 10 December 2014 - 07:01 AM
Hi sorry about that, been busy with RL stuff here.

Sorry yes, the Networking side of things i havent ever worked with so been going through various posts etc about it, and there a lot that refered to RedNet cables. why I thought it was better for some reason.

But anyways, OK so using the RedNet is a no go. I should be looking at the Modem and Network cable setup (I assume that the wirless modem will be basically the same, but ill go study up on those as well)

I Thus far have just Tweaked my coding for my display, I had a lot of unnessesary dupolication of functions etc, and centralised a lot of the variables, like color settings etc… so it would be easy to edit it globally with 1 variable setting.
I have also added a basic login terminal before the button API starts, I mean real basic just a counter with a Must = x till counter =whatever then lockdown (Sleep) system for 2 Minutes and reboot. effectively resetting things.

my pastebin giving crud ill be posting the links to my programs tomorrow for people to give me any ideas as well if its no imposition.

As far as the…. best description I can give it is, wheel of fortune style, program goes.
Im good with the graphics and displaying them on screen.
and can get a cycle through them going. and did the only way I could think of to define the randomness.

Heres the code for that… (again please excuse the noobness) - Still untested, gotta get on my game machine this evening to do so.


--Wheel of Fortune v0.1
--Settings
----------------------------------------------------------
monitor = peripheral.wrap(top)
term.redirect(monitor)
--Images
imgForts	   = paintutils.loadImage(".forts")
imgPlains	  = paintutils.loadImage(".plains")
imgForrest	 = paintutils.loadImage(".forrest")
imgFireIslands = paintutils.loadImage(".fireislands")
----------------------------------------------------------
--Functions
----------------------------------------------------------
function RandomNumber()
rand = math.random(0,8)
return rand
end
function Forts()
  paintutils.drawImage(imgForts, 1, 1)
  os.sleep(7)
if Num < 3 then
  Type = "Forts"
else
  Plains()
end
end
function Plains()
  paintutils.drawImage(imgPlains, 1, 1)
  os.sleep(7)
if Num < 5 then
  Type = "Plains"
else
  Forrest()
end
end
function Forrest()
  paintutils.drawImage(imgForrest, 1, 1)
  os.sleep(7)
if Num < 7 then
  Type = "Forrest"
else
  FireIslands()
end
end
function FireIslands()
  paintutils.drawImage(imgFireIslands, 1, 1)
  os.sleep(7)
if Num < 9 then
  Type = "FireIslands"
else
  RandomNumber()
end
end
----------------------------------------------------------
--Program Execution
----------------------------------------------------------
for i=1,5 do
paintutils.drawImage(imgForts, 1, 1)
os.sleep(1+i)
paintutils.drawImage(imgPlains, 1, 1)
os.sleep(1+i)
paintutils.drawImage(imgForrest, 1, 1)
os.sleep(1+i)
paintutils.drawImage(imgFireIslands, 1, 1)
os.sleep(1+i)
end
Num = RandomNumber()
Forts()
h = fs.open("type", "w")
h.write(TYPE)
h.close()