Because I only get Internet on Wednesdays and Fridays (when I go to places with wireless internet), I got so desperate that I actually taught myself how to make programs on ComputerCraft with nothing but 2 sample programs I downloaded from the Internet, trial and error, 4 days, memory of making programs in the language I usually use, having to rewrite the internet three times, and having to re-install MineCraft once due to corrupting it (this is why I have spare copy of the game). I am willing to bet that your program works 10 times better than mine (there is still a major bug that needs fixing), so I will download it too, but if you want to see mine, I have the programs I designed myself below:
NOTE: Since I usually make programs in a code that is, for the most part, similar to C++, it is somewhat confusing to use Lua, especially when I taught it to myself. If you see any errors, Lua features I didn't use, or similar, please let me know. For the most part, these programs seem to work, though.
There are three programs I designed specifically for a custom village I built, so it will have locations, etc. that are unique to that village. The three programs:
Villager Computers: This program runs on computers for Villagers. The computers have a pressure plate on the front, a wired modem on the right side, and a disk drive on the left. It has 20 "phrase frames" and many more total phrases.
Spoiler
rednet.open ("right")
con = false
while true do
sleep (1)
if redstone.getInput ("front") then
if con == true then
sleep (3)
sleep (math.random (6))
end
ran = math.random (20)
if ran == 10 then
print ("Listening")
os.pullEvent ("rednet_message")
end
ran = math.random (2)
if ran == 1 then
no = ""
elseif ran == 2 then
no = "not "
end
ran = math.random (7)
if ran == 1 then
pla = "Bank"
elseif ran == 2 then
pla = "Park"
elseif ran == 3 then
pla = "Apartment Towers"
elseif ran == 4 then
pla = "Restraunt"
elseif ran == 5 then
pla = "Library"
elseif ran == 6 then
pla = "Museum"
elseif ran == 7 then
pla = "Wilderness"
end
ran = math.random (20)
if ran == 1 then
say = ": Yes."
elseif ran == 2 then
say = ": No."
elseif ran == 3 then
say = ": Possibly."
elseif ran == 4 then
say = ": Meet me at the "..pla.."."
elseif ran == 5 then
say = ": Do you have diamonds?"
elseif ran == 6 then
say = ": Are you skilled at MineCraft?"
elseif ran == 7 then
say = ": The news is "..no.."interesting, you should "..no.."read it."
elseif ran == 8 then
say = ": I do "..no.."like MineCraft."
elseif ran == 9 then
say = ": You should "..no.."go to the "..pla.."."
elseif ran == 10 then
say = ": SPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAMSPAM"
elseif ran == 11 then
say = ": I am "..no.."very skilled at MineCraft."
elseif ran == 12 then
say = ": Have you been to the Nether? I have "..no.."been there."
elseif ran == 13 then
say = ": You should see what is happening at the "..pla.."!"
elseif ran == 14 then
say = ": Are you a monster?"
elseif ran == 15 then
say = ": Do you like MineCraft?"
elseif ran == 16 then
say = ": My Experience Level is "..math.random (50).."."
elseif ran == 17 then
say = ": I once battled "..math.random (14).." monsters at the same time."
elseif ran == 18 then
say = ": Do "..no.."talk to me."
elseif ran == 19 then
say = ": Probably."
elseif ran == 20 then
say = ": Probably not."
end
if con == false then
sel = math.random (18)
sel = sel + 23
con = true
elseif con == true then
ran = math.random (2)
if ran == 1 then
con = false
end
end
rednet.send (sel, say, filt)
print (sel.." Me"..say)
end
end
Player Computer: This simple program runs on the Player's computer, enabling said player to communicate with Villagers.
while true do
print ("Send or Listen? (SpaceBar to Listen)")
local ent = read ()
if ent == (" ") then
print ("Listening for 15 seconds...")
print (rednet.receive (filt, 15))
else
print ("Enter message to send")
local ent = read ()
sel = math.random (18)
sel = sel + 23
rednet.send (sel, ent, filt)
print ("Me: "..ent)
end
end
Server Computer: This program runs on a special computer in the network that does not receive messages, but it instead sends advertisments for certain commercial buildings within the village I created the program for. It also broadcasts randomized News, which are phrase frames that are loaded with randomized objects, places, etc.
--Server Networking Program 0.9
rednet.open ("right")
while true do
sleep (10)
while true do
ran = math.random (7)
if ran == 1 then
nmob = "Villager"
elseif ran == 2 then
nmob = "Zombie"
elseif ran == 3 then
nmob = "Skeleton"
elseif ran == 4 then
nmob = "Creeper"
elseif ran == 5 then
nmob = "Spider"
elseif ran == 6 then
nmob = "Slime"
elseif ran == 7 then
nmob = "Enderman"
end
if nbom == true then
mob = nmob
break
else
nbom = true
mob2 = nmob
end
end
ran = math.random (10)
if ran == 1 then
verb = "attacking"
elseif ran == 2 then
verb = "eating"
elseif ran == 3 then
verb = "stealing"
elseif ran == 4 then
verb = "burning"
elseif ran == 5 then
verb = "burying"
elseif ran == 6 then
verb = "selling"
elseif ran == 7 then
verb = "buying"
elseif ran == 8 then
verb = "wielding"
elseif ran == 9 then
verb = "crafting"
elseif ran == 10 then
verb = "cooking"
end
ran = math.random (18)
if ran == 1 then
obj = "tree"
elseif ran == 2 then
obj = "Computer"
elseif ran == 3 then
obj = "Dirt Block"
elseif ran == 4 then
obj = "Iron Block"
elseif ran == 5 then
obj = "sword"
elseif ran == 6 then
obj = "Cake"
elseif ran == 7 then
obj = "TNT Block"
elseif ran == 8 then
obj = "pickaxe"
elseif ran == 9 then
obj = "Ender Pearl"
elseif ran == 10 then
obj = "Obsidian Block"
elseif ran == 11 then
obj = "Chest"
elseif ran == 12 then
obj = "hoe"
elseif ran == 13 then
obj = "axe"
elseif ran == 14 then
obj = "spade"
elseif ran == 15 then
obj = "Fishing Rod"
elseif ran == 16 then
obj = "Gold Block"
elseif ran == 17 then
obj = "Diamond"
elseif ran == 18 then
obj = "Crafting Table"
end
ran = math.random (7)
if ran == 1 then
tim = "a few minutes ago"
elseif ran == 2 then
tim = "last night"
elseif ran == 3 then
tim = "yesterday"
elseif ran == 4 then
tim = "the day before yesterday"
elseif ran == 5 then
tim = "a week ago"
elseif ran == 6 then
tim = "two weeks ago"
elseif ran == 7 then
tim = "a month ago"
end
ran = math.random (7)
if ran == 1 then
pla = "Restraunt"
elseif ran == 2 then
pla = "Park"
elseif ran == 3 then
pla = "Wilderness"
elseif ran == 3 then
pla = "Library"
elseif ran == 4 then
pla = "Museum"
elseif ran == 5 then
pla = "Apartment Towers"
elseif ran == 6 then
pla = "Computer Shop"
elseif ran == 7 then
pla = "Bank"
end
ran = math.random (2)
if ran == 1 then
any = obj
elseif ran == 2 then
any = mob
end
sel = math.random (18)
sel = sel + 23
ran = math.random (17)
if ran == 1 then
say = "Ad: The Village Restraunt has beef, fish, and more! Eat there today!"
elseif ran == 2 then
say = "Ad: Eat at the Village Restraunt! It has many different foods for a low price."
elseif ran == 3 then
say = "Ad: Tired of hunting to get your food? Go to the Restraunt instead!"
elseif ran == 4 then
say = "Ad: The Museum now has the first watch! See it today!"
elseif ran == 5 then
say = "Ad: Sit down and relax at the Library. There are plenty of books and a public computer!"
elseif ran == 6 then
say = "Ad: The Computer Store now has GoldRunner by NitrogenFingers! Buy today!"
elseif ran == 7 then
say = "Ad: The Computer store has all your computing needs, from modems to printers!"
elseif ran == 8 then
say = "Ad: Apartment Towers has wireless computers in each room! Go to the Lobby to get an Apartment."
elseif ran == 9 then
say = "Ad: The rooms in Apartment Towers are a full 5x5 meters! Enjoy living in these rooms today!"
elseif ran == 10 then
say = "Ad: The Doctor's Office will heal you fast. Get a checkup today!"
elseif ran == 11 then
say = "News: A local "..mob2.." was seen "..verb.." a "..any.." "..tim.."."
broad = true
elseif ran == 12 then
say = "News: A local "..mob2.." went missing "..tim..". It's favourite food is "..any.."s."
broad = true
elseif ran == 13 then
say = "News: A "..obj.." was stolen "..tim..". It's owner says that the thief may have been a "..mob.."."
broad = true
elseif ran == 14 then
say = "News: A shortage of "..any.."s has been reported "..tim..". Experts say that "..mob2.."s may be affected the most."
broad = true
elseif ran == 15 then
say = "News: A lost "..obj.." was found "..tim.." near the "..pla..". We think it may have belonged to a "..mob.."."
broad = true
elseif ran == 16 then
say = "Ad: If you fall into lava, chances are you will lose your items. Protect what you have earned at the Bank!"
elseif ran == 17 then
say = "Ad: It could happen to you! Put your items in the Bank today!"
end
if broad == true then
rednet.broadcast (say, filt)
else
rednet.send (sel, say, filt)
end
print (say)
end