Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: AndersM on Sun 16/11/2003 19:18:00

Title: Use score as money ?
Post by: AndersM on Sun 16/11/2003 19:18:00
Can I do that?

I know that I can use 'GiveScore (-10);' if the player buys something that
costs $10, but can I add something that displays "You can't afford that" if the
score is less than 10? It does not have to be fancy, just something like
'if score<10 display message, else Givescore (-10); ad inventory...'

Please help
Title: Re:Use score as money ?
Post by: Kweepa on Sun 16/11/2003 19:21:45
Ummm, it seems you have answered your own question.
:)
Title: Re:Use score as money ?
Post by: AndersM on Sun 16/11/2003 19:23:31

Quote from: SteveMcCrea on Sun 16/11/2003 19:21:45
Ummm, it seems you have answered your own question.

Do you realy mean that 'if score<10' works? I've never tried it..
Title: Re:Use score as money ?
Post by: Squinky on Sun 16/11/2003 19:29:52
I've never messed with the score thingt in ags, so I'd just use a globalint to store it. but either way is prolly good

if (GetGlobalInt (1)<=10){
Display ("You can't afford that");
Display ("You only have %d Dollars",GetGlobalInt (1));
}
else if (GetGlobalInt (1)>=10){
Display ("You purchase the stuff");
SetGlobalInt (1,GetGlobalInt (1)-10);
Display ("You have %d Dollars Left", GetGlobalInt (1));
}
}
Thats how I'd probably try it, might actaully be easier with the score though
Title: Re:Use score as money ?
Post by: Pumaman on Sun 16/11/2003 19:34:04
The variable name is "game.score"
Title: Re:Use score as money ?
Post by: Kweepa on Sun 16/11/2003 19:37:02
Quote from: MrMasse on Sun 16/11/2003 19:23:31
Do you realy mean that 'if score<10' works? I've never tried it..

Well, no, but a quick look at the manual reveals "game.score < 10" will work.
So,

// item costs 10 "dollars"
if (game.score < 10) { // do not use <= as in Squinky's code! :)
Display("You're too poor.");
}
else {
Display("You buy it. You feel a buzz of buyers' excitement, quickly followed by a pang of spendthrifts' guilt and a jolt of suckers' disappointment.");
GiveScore(-10);
AddInventory(1337);
}

Steve
Title: Re:Use score as money ?
Post by: Squinky on Sun 16/11/2003 19:42:59
Heh, whats wrong with my code? Works for me...

My understanding, from the manual is that:

> this will compare values and then proceed
>= This will dosent mention comparing in the manual, but works okay for me.

Is there truley any difference?
Title: Re:Use score as money ?
Post by: CB.. on Mon 17/11/2003 01:08:56
yu can alter the score text in the gui bar to read as money instead of score to add interest

GUI

status bar

Money @SCORE@ of @TOTALSCORE@ .


or

members of the voting public@SCORE@ of @TOTALSCORE@ .

whatever yu need

hmm a game to simulate a general election? as in that new republic idea? dont see why not..get enough votes win the game  
Title: Re:Use score as money ?
Post by: TerranRich on Mon 17/11/2003 03:52:09
Squinky: > means "greater than", >= means "greater than OR equal to" :)
Title: Re:Use score as money ?
Post by: Squinky on Mon 17/11/2003 04:14:41
Thanks Terran
Title: Re:Use score as money ?
Post by: AndersM on Mon 17/11/2003 15:04:31
This is the script-code i use:

function character2_a() {
 // script for character2: Talk to character
if (game.score < 10){
Display("You're too poor.");
}
else (game.score > 10)
Display("You buy the item");
GiveScore(-10);
AddInventory(1);
}
}
(http://function%20character2_a()%20{but it only returns Parse error: unexpected 'else' (//http://Parse%20error:%20unexpected%20'else')

Please help
Title: Re:Use score as money ?
Post by: Squinky on Mon 17/11/2003 15:19:32
I got it to work by turning your "else" into an "else if". I think if you wanted to use else you need to get rid of that condition, otherwise if there is a condition, you should use else if....I believe, heh...

// script for character2: Talk to character
if (game.score < 10){
Display("You're too poor.");
}
else if (game.score > 10)
Display("You buy the item");
GiveScore(-10);
AddInventory(1);
Title: Re:Use score as money ?
Post by: AndersM on Mon 17/11/2003 15:32:31
It works so far, but he still looses the money if he can't afford the object, so i sorted it out by putting it 'upside down'


I allso had to put >9 else he woudn't buy it if he had 10, cos
>10 means greater than 10. (someone mentioned this, i think)

Thanx alot everybody,  I'll blaim you all if it crashes / doesn't work (http://function%20character2_a(){
Title: Re:Use score as money ?
Post by: Squinky on Mon 17/11/2003 16:18:51
Well, if I understand you right, you should leave it at ten and change it to <=10....That would be more accurate?
Title: Re:Use score as money ?
Post by: Ginny on Mon 17/11/2003 19:38:41
>=10 instead of >9 if I'm not mistaken, though either way works just aswell.
Title: Re:Use score as money ?
Post by: AndersM on Mon 17/11/2003 20:57:21
I'm happy with it now. Maybe this is something for the 'technical archive' ?