Quoting jigalypuff.
sorry man this does not work,
Twas an example only.
Usage is optional (pattern ON).
// maybe try?
function creditsf_add(_n) {
if (_n < 0) {
if ((credits_n + _n) < 0) {
return(0);
}
}
credits_n += _n;
creditsf_update();
return(1);
}
// in main function (or use starter)
function main() {
// level load
creditsf_add(10000);
}
//...
// buy ship code
if (creditsf_add(-shipCost)) {
// can afford
// transaction OK
// add ship
} else {
// come back with more dough captain
}
//...
// put ship back
creditsf_add(shipCost); // refund full cost
...or alternately deal with credits_n directly (or similar) and remember to invoke str_for_num(credits_s, credits_n)
(or similar) when appropriate?
...or, create an updating while(1) { wait(1); } loop for credits_n, credits_s (or similar) and update using str_for_num there?