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");
}
Creating levels is fascinating
User avatar
LECZ
 
Posts: 145
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()
I made a worldmap, see “Puzzles or Platforms?
User avatar
DevonST
 
Posts: 130
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");
}
Creating levels is fascinating
User avatar
LECZ
 
Posts: 145
Joined: 11 Jun 2021, 21:13

Re: I need help with a script

Postby DevonST » 18 Jul 2021, 07:45

Yeah, that should work
I made a worldmap, see “Puzzles or Platforms?
User avatar
DevonST
 
Posts: 130
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:
Creating levels is fascinating
User avatar
LECZ
 
Posts: 145
Joined: 11 Jun 2021, 21:13

Who is online

Users browsing this forum: No registered users and 0 guests