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
Ummm, it seems you have answered your own question.
:)
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..
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
The variable name is "game.score"
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
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?
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
Squinky: > means "greater than", >= means "greater than OR equal to" :)
Thanks Terran
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
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);
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(){
Well, if I understand you right, you should leave it at ten and change it to <=10....That would be more accurate?
>=10 instead of >9 if I'm not mistaken, though either way works just aswell.
I'm happy with it now. Maybe this is something for the 'technical archive' ?