I made the internet with computercraft in minecraft! I saw other people do this, but it didn't fulfil my hunger for internet in minecraft, so i took time out of my day to program it for those views. bit.ly/3oUsGzT
full code:
client Web browser:
write("url:")
x1,y1 = term.getCursorPos()
m1 = read()
term.setCursorPos(x1+#m1,y1)
write("/")
m2 = read()
multishell.setTitle(multishell.getCurrent(),m1.."/"..m2)
while true do
rednet.close("top")
rednet.open("top")
rednet.send(7,{m1,m2})
id, ms = rednet.receive(0.5)
if ms == nil then
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
print("lost connection...")
end
if id == 7 then
for sit = 1, #ms do
os.runWebCode(ms,sit)
end
end
rednet.receive(0.000000001)
end
-- end of code
client web API, work in progress:
function WebRun(ms,sit)
if ms[sit][1] == "clear" then
term.clear()
term.setCursorPos(1,1)
end
if ms[sit][1] == "print" then
print(ms[sit][2])
end
if ms[sit][1] == "setBgColor" then
term.setBackgroundColor(ms[sit][2])
term.clear()
term.setCursorPos(1,1)
end
if ms[sit][1] == "setCursorPos" then
term.setCursorPos(ms[sit][2],ms[sit][3])
end
end
os.runWebCode = WebRun
-- end of code
DNS server:
pastebin get TE56YsBn
the code was too long for youtube so just paste that in the craftos cmd
that server in the video:
wow = math.random(1,100)
multishell.launch({},"rng.lua")
while true do
rednet.close("top")
rednet.open("top")
math.random(1,10000)
id, ms = rednet.receive()
if ms ~= nil then
if id == 7 and ms ~= nil then
print(ms[2].."/"..ms[3].."|"..ms[4].."| at "..os.clock())
end
if ms[3] == "" then
file = {
{"clear"},
{"setBgColor",colors.blue},
{"print","wow bro this is computer "..ms[4]}
}
end
if ms[3] == "test" then
file = {
{"setBgColor",colors.orange},
{"print","wow bro you discovered the secret webpage"}
}
end
if false then
if ms[3] == "math" then
o = fs.open("number.txt","r")
file = {
{"setBgColor",colors.black},
{"print",o.readAll()}
}
o.close()
end
end -- disabled pls configure rng to use
if file ~= nil then
rednet.send(7,{"smsg",file,ms[4]})
end
end
end
-- end of code
PLEASE NOTE YOU HAVE TO INSERT THE PROPER IDs for it to work
if you need any help i can help you in comments
in this example dns server is computer 7
and that random server is 8
and this assumes the modems are on top
#computercraft
#computer
#computerscience
#internet
#video
#minecraft
#minecraftmods
#lua
Негізгі бет I made an internet system in minecraft computercraft!
Пікірлер: 37