Compare commits

...
2 Commits
Author SHA1 Message Date
minecartchris 94683e34bf fixed more shit 2026-02-01 17:47:46 -06:00
minecartchris c4defcd9d9 Fixed tons of shit 2026-02-01 17:34:39 -06:00
+65 -3
View File
@@ -1,4 +1,54 @@
--slot2
rednet.open("back")
local function interactWithCard(userUUID, mode, money)
if mode == "updateBalance" then
rednet.broadcast({
uuid = userUUID,
amount = money,
type = "set"
}, "machineBalanceModifier")
end
if mode == "getBalance" then
local _, _, cardUUID = os.pullEvent("nfc_data")
rednet.broadcast({
card = cardUUID
}, "getAccountData")
while true do
local id, message = rednet.receive("server_response", 10)
if not id then
print("the server is down")
print("please ping @minecartchris")
sleep(30)
--shell.run("reboot")
end
if message.type == "account_data" and message.cardId == cardUUID then
local money = message.balance
local playerUUID = message.uuid
local username = message.username
return money, playerUUID, username
end
end
end
end
os.pullEvent= function(...)
while true do
local t = table.pack(os.pullEventRaw(...))
if t[1] ~= "terminate" then
return table.unpack(t,1,t.n)
end
end
end
if fs.exists("/disk/terminate") then
error("Service mode active",2)
end
math.randomseed(os.epoch("utc"))
for i = 1, 5 do math.random() end
@@ -14,8 +64,8 @@ local function input(message)
return io.read()
end
local function calculate_winnings(got, bet)
local b = tonumber(bet) or 0
local function calculate_winnings(got, b)
--local b = tonumber(bet) or 0
if got[1] == got[2] and got[2] == got[3] then
return b * 10
elseif got[1] == got[2] or got[2] == got[3] or got[1] == got[3] then
@@ -73,7 +123,16 @@ end
local function run()
term.clear()
local bet_input = input("Bet: ")
print("Welcome to the Slot Machine!")
print("Please swipe your card to begin")
money, playerUUID, username = interactWithCard(nil, "getBalance", nil)
term.clear()
print("Welcome ".. username .." have fun!")
local bet_input = tonumber(input("Bet: "))
if money < bet_input then
print("please get more money or bet less as you can't bet more then you have")
end
local final = draw()
local current = {nil, nil, nil}
@@ -88,6 +147,8 @@ local function run()
local w, h = term.getSize()
term.setCursorPos(math.floor(w/2) - 6, math.floor(h/2) + 3)
money = money + winnings
interactWithCard(playerUUID, "updateBalance", money)
print("WON: " .. winnings)
for i = 1, 4 do
@@ -97,6 +158,7 @@ local function run()
sleep(0.3)
draw_display(final)
end
sleep(30)
end
shell.execute("clear")
while true do