Page 1 of 1

Some script question

PostPosted: 10 Feb 2018, 16:44
by sinisa3games
Is there a script like
If tux coins>500
then tux coins -500 ?
sorry im new :cry:

Re: Some script question

PostPosted: 10 Feb 2018, 16:50
by mteufel
There might be. But SuperTux is supposed to be a fun game. This seems to be something mean. So don't do it (and that's why I won't provide support on this, either).

Re: Some script question

PostPosted: 10 Feb 2018, 16:52
by sinisa3games
i meant it like a shop

Re: Some script question

PostPosted: 10 Feb 2018, 18:59
by mteufel
You can use
{l Code}: {l Select All Code}
sector.Tux.add_coins(amount);
in a level, where amount can also be a negative integer (it will then take Tux's coins).

However, there is, at the time of writing this, no way of checking whether Tux has enough coins. So a store would be quite silly. (The player could still buy stuff, without enough coins)

We might integrate the concept of a store in the main game in the future, though.

Re: Some script question

PostPosted: 10 Feb 2018, 19:02
by sinisa3games
wait, can tux have minus coins? :shock:

Re: Some script question

PostPosted: 10 Feb 2018, 21:05
by mteufel
No. But when you add negative coins, they will be taken from Tux (imagine, you have some coins. you owe someone else some coins. if you add to something you have (positive coins) some debt (negative coins), you will have less coins). At some point, it will reach 0 points. You can then still take Tux coins away, but none will actually be taken because Tux can't have less than 0 coins. Hence, Tux can buy everything in your store, without paying anything.

Re: Some script question

PostPosted: 10 Feb 2018, 21:12
by sinisa3games
is coin checking going to be added?

Re: Some script question

PostPosted: 10 Feb 2018, 22:37
by manuel
Adding a shop to the game was at least a suggestion for the next release. Therefore, it would make sense to add something like this, but I really don't know. (And I'm no developer).

Re: Some script question

PostPosted: 11 Feb 2018, 10:55
by mteufel
It has been added (well, I'm only awaiting review) to the development version soon: https://github.com/SuperTux/supertux/pull/763.

In future releases you will be able to use something like this:

{l Code}: {l Select All Code}
if (sector.Tux.get_coins() > 50) {
    sector.Tux.add_coins(-50);
    sector.Tux.add_bonus("fireflower");
}