Some checks failed
Deploy / deploy (push) Has been cancelled
Comprehensive docs covering architecture, all components, Docker services, environment variables, MetaMask connection (desktop + mobile), administration commands, and troubleshooting. Also adds Lua scripts to repo for version control, including the periodic chain sync loop (every 30s) in the mainframe. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
97 lines
2.2 KiB
Lua
97 lines
2.2 KiB
Lua
MAINFRAME_ID = 7
|
|
|
|
-- AfterCoin Bridge config
|
|
local BRIDGE_URL = "http://afc-bridge:3001"
|
|
|
|
function addPlayer(player, name)
|
|
rednet.send(MAINFRAME_ID, {type="addPlayer", player=player, name=name}, "otto")
|
|
rednet.receive("otto")
|
|
return
|
|
end
|
|
|
|
-- Get wallet info from bridge API
|
|
function getWalletInfo(diskId)
|
|
local ok, result = pcall(function()
|
|
local response = http.get(BRIDGE_URL .. "/api/wallet/" .. tostring(diskId))
|
|
if not response then return nil end
|
|
local data = textutils.unserialiseJSON(response.readAll())
|
|
response.close()
|
|
return data
|
|
end)
|
|
if ok and result and result.success then
|
|
return result
|
|
end
|
|
return nil
|
|
end
|
|
|
|
local drive = peripheral.wrap("top")
|
|
rednet.open("left")
|
|
|
|
while true do
|
|
term.clear()
|
|
term.setCursorPos(1,1)
|
|
term.setTextColor(colors.yellow)
|
|
print("=== Card Generator ===")
|
|
print("")
|
|
print("Insert a floppy disk")
|
|
print("in the drive above.")
|
|
|
|
os.pullEvent("disk")
|
|
os.sleep(0.5)
|
|
|
|
local player = drive.getDiskID()
|
|
if player then
|
|
term.setTextColor(colors.white)
|
|
print("")
|
|
term.write("Username: ")
|
|
local name = read()
|
|
term.setTextColor(colors.yellow)
|
|
print("Generating card for "..name.."...")
|
|
|
|
addPlayer(player, name)
|
|
drive.setDiskLabel(name.."'s L'Otto Card - $0")
|
|
local mountPath = drive.getMountPath()
|
|
if mountPath then
|
|
local filePath = fs.combine(mountPath, "bal")
|
|
local file = fs.open(filePath, "w")
|
|
if file then
|
|
file.write("0")
|
|
file.close()
|
|
end
|
|
end
|
|
|
|
-- Display wallet info for MetaMask
|
|
term.setTextColor(colors.lime)
|
|
print("Card created!")
|
|
print("")
|
|
local wallet = getWalletInfo(player)
|
|
if wallet then
|
|
term.setTextColor(colors.cyan)
|
|
print("== AfterCoin Wallet ==")
|
|
term.setTextColor(colors.white)
|
|
print("Address:")
|
|
print(wallet.address)
|
|
print("")
|
|
print("To view in MetaMask:")
|
|
print("Network: AfterLife")
|
|
print("RPC: play.consultoria-as.com:8545")
|
|
print("Chain ID: 8888")
|
|
print("")
|
|
print("Import wallet key at:")
|
|
print("/api/wallet/" .. tostring(player))
|
|
print("")
|
|
term.setTextColor(colors.yellow)
|
|
print("Press any key to eject...")
|
|
os.pullEvent("key")
|
|
end
|
|
|
|
drive.ejectDisk()
|
|
term.setTextColor(colors.lime)
|
|
print("Ejected.")
|
|
else
|
|
term.setTextColor(colors.red)
|
|
print("ERROR: Could not read disk.")
|
|
os.sleep(3)
|
|
end
|
|
end
|