Are you asking if someone is willing to create the code for you? If that's the case I can say that lots of people don't want to create a code for you..
I don't mean to sound harsh but this is a section where people help you out if you stumble upon a problem or something you want help with, This is not a section you can ask for someone to make the code for you, I'd suggest you would have put this in general if you are asking that( You can ask a moderator to move it )
So this is some things you need help with?
Events
Redstone
Fs API
Events
Events
This is an example how you can use the events system
local event, param1 = os.pullEvent() -- This is waiting for an event to be pulled
if event == "disk" then
print("A disk has been inserted!")
else
print(event .. ":" .. param1)
end
You can also add something like "key" to only pull that event
local event, param1 = os.pullEvent("key")
print("A key has been pressed")
Redstone
Redstone
Turning redstone on and off
rs.setOutput("left", true)
So this is quite simple, You choose the side you want to change the redstone output off(left, right, bottom, top, front, back) and you set it to true to turn it on and false to turn it off.Fs API
Fs API
I'm showing how you can use th fs API since that would be needed if you save the 'cash' in a file and then want to check it
So first of all I'm guessing you want it saved onto the disk drive right? And it needs to be a number ofcourse.
The first time you create your disk drive file
local cash = 0
local file = fs.open("disk/cashfile_data","w")
file.writeLine(cash)
file.close()
So now the file is created in the disk drive named as 'cashfile_data'
You can check that it's there by doing 'cd disk' and then 'ls' if you want to check what's in the file call 'edit cashfile_data'
Anyway.. Now you kinda want to check how much cash is on it
local file = fs.open("disk/cashfile_data","r")
local cash = file.readLine() -- Reads the first line in the file
file.close()
if not tonumber(cash) then
error("It was not a number in the file! D:",0) -- Erroring if the first line in the file was not a number
end
So how I would do that when doing +1 with the 'cash' is something like this
Example
while true do
local evt, side = os.pullEvent("disk")
print("Disk inserted")
if fs.exists("disk/cashfile_data") then
print("cashfile_data found")
local file = fs.open("disk/cashfile_data","r")
local cash = file.readLine()
file.close()
if not tonumber(cash) then
fs.delete("disk/cashfile_data")
error("Cashfile corrupt, Deleting..", 0)
end
cash = cash + 1
local file = fs.open("disk/cashfile_data","w")
file.writeLine(cash)
file.close()
else
local file = fs.open("disk/cashfile_data","w")
file.writeLine("0")
file.close()
end
disk.eject(side) -- Ejecting the disk when finished
end
And if you want to check if the user has enough 'cash' you can do something like this
Example
local game = "TestGame" --# The game that you want to run if the user has enough cash
while true do
local evt, side = os.pullEvent("disk")
if fs.exists("disk/cashfile_data") then
local file = fs.open("disk/cashfile_data","r")
local cash = file.readLine()
if not tonumber(cash) then
disk.eject(side)
error("cashfile_data was corrupt! D:",0)
end
if cash > 1 then
print(cash .. "$ - 1$")
cash = cash - 1
local file = fs.open("disk/cashfile_data","w")
file.writeLine(cash)
file.close()
sleep(.8)
shell.run(game)
else
disk.eject(side)
error("Insufficient funds! D:",0)
end
else
disk.eject(side)
end
end