I’m trying to make it so a shop has inflation due to having demand.
Here’s the problem. The purchase won’t show and the price does not update. Here are my blocks (inside a trigger)
Anybody know why it won’t update?
If so, can they explain and/or make a guide?
The inflation variable won’t save in between run times. You’ll need to use a property for the inflation amount.
Getrithekd
I’m not very good at code, but would any of this code apply to this topic?
// Initialize variables
set inflation to 0
set price to 0
set gain to 1
// Function to update price based on inflation
define updatePrice
set inflation to (inflation + 25)
set price to (0 + inflation)
// Update display of price
set displayPrice to price
// Function to handle purchase
define handlePurchase
if (Get Property 'Score' ≥ price) then
// Deduct price from score
Set Property 'Score' to (Get Property 'Score' - price)
// Increase CPS
Set Property 'CPS' to (Get Property 'CPS' + gain)
// Update price for next purchase
updatePrice
// Update purchase status display
set purchaseStatus to "Purchase successful"
else
// Update purchase status display
set purchaseStatus to "Not enough score"
end
// Call updatePrice initially to set the first price
updatePrice
Criticize me
Thanks for the input lol
First up, you can’t define functions in gkc blocks. Second, you didn’t set a property called inflation. It’s not really necessary to put that in a dropdown lol.
1 Like
This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.