How do I make a button that saves and loads the game
im trying to make a incremental as a beginner coder but I'm having trouble with the saving mechanic
im trying to make a incremental as a beginner coder but I'm having trouble with the saving mechanic
The storage object allows for the permanent storage of your application data. You can use it to store user progress, highscores or other status information about your game or project.
storage.set( name , value )
Stores your value permanently, referenced by the string name. The value can be any number, string, list or structured object.
storage.get( name )
Returns the value permanently recorded under reference string name. Returns 0 when no such record exists.
thanks but the main problem I'm experiencing is the buttons simply wont show up even tho I am using DrawUI = function() thanks anyway because I did not know about the storage thing
DrawUI? its just draw = function() end
just in case here's all them
init = function()
end
update=function()
end
draw = function()
end
this is the code I tried all of your tips but they don't work this is the base code I currently have I hope this helps
buttons = []
buttons.push(
object
x = -90
y = -50
width = 80
height = 25
text = "Save"
action = function() storage.set(Points, Points)
scale = 1
alpha = 4
end
)
end
updateUI = function()
for button in buttons
//check hover
button.scale = 1
if checkRoundMouseHover(button.x, button.y,
button.width, button.height) then
button.alpha = 1
if mouse.press then
button.action()
end
if mouse.pressed then
button.scale = 1.1
end
else
button.alpha = 0.7
end
end
end
drawUI = function()
for button in buttons
screen.setDrawScale(button.scale, button.scale)
screen.setAlpha(button.alpha)
screen.fillRoundRect(button.x-100, button.y-10,
button.width+50, button.height+50,"rgb(255,255,255)")
screen.drawSprite("save", -100, -10, 90, 90)
screen.drawText(button.text, button.x-100, button.y-10)
screen.setDrawScale(1, 1)
screen.setAlpha(1)
end
end```
there is a init = function() at the top
could you invite me to the project i need to see all your scripts
quick question did you use ai? i just need to know