Can't store variables

I was making a counter in pulp, and decided to make a system to save the current number for the next time people play the game, but it wouldn't restore the number once I rebooted it. This is the code:

on start do
restore "count"
log "restored values"
end

on store do
store "count"
log "stored value"
end

It logs that it did, but doesn't actually restore the variable. If anyone knows how to fix this, tell me.

"on store do" is not a default event in Pulp. You'd have to either call that custom event some way, like when interacting with a sprite:

on interact do
tell event.player to
call store
end
end

This might not work since there's a function called store. An easier solution (and the one I just implemented in my game), would be to store on a button press.

in the player script:
on confirm do
store "count"
end

Or you could have it every time you change rooms (a good and commonsense way to store stuff in pulp games) using "on enter do."

Also worth clarifying, store x only queues up that variable to be written to permanent storage - you will need to change rooms or call store on its own to actually write to disk.

In other words if you were restarting the game immediately after that store without changing rooms that'd explain why you weren't seeing it actually get stored.

1 Like