0
Web IDE main
9 commitsoaky Update mob-farm
9ff9e61e 2026-09-25
main | 2026-09-25 |
| 2026-09-25 |
Overview
MITMob Farm
Quick Install on your ComputerCraft device
Type this command in the terminal:
hub get mob-farm
client.lua main
-- ============================================================
-- Mob Farm Client
-- Läuft auf dem Monitor-Computer (mit Modem + Monitor)
-- ============================================================
local CHANNEL = 42
local modem = peripheral.find("modem") or error("Kein Modem gefunden!", 0)
local monitor = peripheral.find("monitor") or error("Kein Monitor gefunden!", 0)
modem.open(CHANNEL)
monitor.setTextScale(1)
local C = {
BG = colors.black,
TITLE_BG = colors.gray,
TITLE_FG = colors.white,
ON_BG = colors.green,
OFF_BG = colors.red,
BTN_FG = colors.white,
TOGGLE_BG = colors.blue,
STATUS_FG = colors.lightGray,
}
local state = {
farmActive = false,
expMode = false,
}
local connected = false
local lastMessage = "Verbinde..."
local buttons = {}
local function send(msg)
modem.transmit(CHANNEL, CHANNEL, msg)
end
local function drawBtn(mon, btn, active)
local bg = active and btn.bgOn or btn.bgOff
local lbl = active and btn.labelOn or btn.labelOff
mon.setBackgroundColor(bg)
mon.setTextColor(btn.fg or C.BTN_FG)
for dy = 0, 2 do
mon.setCursorPos(btn.x1, btn.y + dy)
mon.write(string.rep(" ", btn.x2 - btn.x1 + 1))
end
local bw = btn.x2 - btn.x1 + 1
local tx = btn.x1 + math.floor((bw - #lbl) / 2)
mon.setCursorPos(tx, btn.y + 1)
mon.write(lbl)
end
local function redraw()
local w, h = monitor.getSize()
monitor.setBackgroundColor(C.BG)
monitor.clear()
-- Titel
monitor.setBackgroundColor(C.TITLE_BG)
monitor.setTextColor(C.TITLE_FG)
monitor.setCursorPos(1, 1)
monitor.write(string.rep(" ", w))
local title = "[ MOB FARM ]"
monitor.setCursorPos(math.floor((w - #title) / 2) + 1, 1)
monitor.write(title)
-- Status
local connText = connected and "Verbunden" or lastMessage
monitor.setBackgroundColor(C.BG)
monitor.setTextColor(connected and colors.lime or colors.orange)
monitor.setCursorPos(1, 2)
monitor.write(string.rep(" ", w))
monitor.setCursorPos(2, 2)
monitor.write(connText)
-- Layout: 2 Buttons nebeneinander
local pad = 1
local gap = 1
local bw = math.floor((w - 2 * pad - gap) / 2)
local x1l = pad + 1
local x2l = pad + bw
local x1r = pad + bw + gap + 1
local x2r = w - pad
buttons = {
{
labelOn = "FARM: AN",
labelOff = "FARM: AUS",
bgOn = C.ON_BG,
bgOff = C.OFF_BG,
x1 = x1l, x2 = x2l, y = 4,
action = function() send({ type = "toggle_farm" }) end,
getActive = function() return state.farmActive end,
},
{
labelOn = "MODUS: EXP",
labelOff = "MODUS: LOOT",
bgOn = C.TOGGLE_BG,
bgOff = C.TOGGLE_BG,
x1 = x1r, x2 = x2r, y = 4,
action = function() send({ type = "toggle_mode" }) end,
getActive = function() return state.expMode end,
},
}
for _, btn in ipairs(buttons) do
drawBtn(monitor, btn, btn.getActive())
end
-- Statuszeile unten
local farmStr = state.farmActive and "AN" or "AUS"
local modeStr = state.expMode and "EXP" or "Loot"
local statusLine = "Farm: " .. farmStr .. " | " .. modeStr
monitor.setBackgroundColor(C.BG)
monitor.setTextColor(C.STATUS_FG)
monitor.setCursorPos(1, h)
monitor.write(string.rep(" ", w))
monitor.setCursorPos(math.floor((w - #statusLine) / 2) + 1, h)
monitor.write(statusLine)
end
local function handleClick(x, y)
for _, btn in ipairs(buttons) do
if x >= btn.x1 and x <= btn.x2 and y >= btn.y and y <= btn.y + 2 then
btn.action()
return
end
end
end
send({ type = "request_state" })
redraw()
os.startTimer(5)
while true do
local ev = { os.pullEvent() }
local name = ev[1]
if name == "monitor_touch" then
local _, _, tx, ty = table.unpack(ev)
handleClick(tx, ty)
elseif name == "modem_message" then
local _, _, ch, _, msg = table.unpack(ev)
if ch == CHANNEL and type(msg) == "table" then
if msg.type == "state" then
state = msg.state
connected = true
lastMessage = "Verbunden"
redraw()
end
end
elseif name == "timer" then
send({ type = "request_state" })
os.startTimer(5)
end
end Usage
Once installed with hub get mob-farm, run:
mob-farmCareful what you run: This script was written by oaky, not by us.
It runs with full access to the computer you install it on — it can read and delete files there.
Read it before you run it.
About
No description provided.
MIT License
★ 0 stars
0 in-game downloads
Hardware Targets
computer