I need help with a script

I need help with a script

Postby LECZ » 16 Jul 2021, 17:42

I am making a shop and this is the problem

Every time Tux wants to buy something and doesn't bring coins, he buys it anyway.

I did this script but it doesn't work for me:

if("coins" >= 50){
Tux.add_coins(-50);
Tux.add_bonus("grow");
}
User avatar
LECZ
 
Posts: 16
Joined: 11 Jun 2021, 21:13

Re: I need help with a script

Postby DevonST » 17 Jul 2021, 07:29

"coins" is a string of text because it is inside quotation marks. A good programming language would tell you that strings are not comparable with numbers. You should replace "coins" with Tux.get_coins()
User avatar
DevonST
 
Posts: 131
Joined: 18 Mar 2018, 11:01
Location: Germany

Re: I need help with a script

Postby LECZ » 17 Jul 2021, 17:04

DevonST {l Wrote}:"coins" is a string of text because it is inside quotation marks. A good programming language would tell you that strings are not comparable with numbers. You should replace "coins" with Tux.get_coins()



something like that?:

if(Tux.get_coins() >= 50){
Tux.add_coins(-50);
Tux.add_bonus("grow");
}
User avatar
LECZ
 
Posts: 16
Joined: 11 Jun 2021, 21:13

Re: I need help with a script

Postby DevonST » 18 Jul 2021, 07:45

Yeah, that should work
User avatar
DevonST
 
Posts: 131
Joined: 18 Mar 2018, 11:01
Location: Germany

Re: I need help with a script

Postby LECZ » 19 Jul 2021, 21:16

DevonST {l Wrote}:Yeah, that should work


Thanks for your help if it works :cool:
User avatar
LECZ
 
Posts: 16
Joined: 11 Jun 2021, 21:13

Who is online

Users browsing this forum: No registered users and 1 guest