Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gabarts on Mon 24/11/2014 12:37:45

Title: Inventory+Player/Score [SOLVED]
Post by: Gabarts on Mon 24/11/2014 12:37:45
Hello guys,

it's quite a while I don't ask for help (this can be positive, I learned something :))
Anyway, I cannot find a thread about this, maybe I'm searching the wrong code or scripting.

What I need to do:

-Checking if my player is in a certain room and then if item is used start the code.

At the moment for that item is assigned a basic action (like player.Say or whatever)
I need the condition to tell if player is in a room. Could be something like this?

Code (ags) Select
if (player.Room(2)) { //OR if (player.Room == 2)) {

The second thing is totally different:

What scripting I need to use to check if the player has a certain score (I've used GiveScore(); to assign a score) and then made a GUI to return it.

Thanks
Title: Re: Inventory+Player in room
Post by: Vincent on Mon 24/11/2014 13:08:44
A quick response could be like this

Quote from: Gabarts on Mon 24/11/2014 12:37:45
-Checking if my player is in a certain room

Code (ags) Select

if (player.Room == 1) //OR if (player.PreviousRoom == 1)


Quote from: Gabarts on Mon 24/11/2014 12:37:45
and then if item is used

Do you mean :

InventoryItem* Character.ActiveInventory

// This property is useful in "Use inventory on hotspot/character/etc" events, to find out which inventory item the player is trying to use on the target.


Quote from: Gabarts on Mon 24/11/2014 12:37:45
I need to use to check if the player has a certain score


// repeatedly_execute()
Label1.Text = String.Format("%d", game.score);



Quote from: Gabarts on Mon 24/11/2014 12:37:45
and then made a GUI to return it.

???
Title: Re: Inventory+Player in room
Post by: Gabarts on Mon 24/11/2014 16:03:06
Sorry, it was unclear.

First thing ok, it's how I tought. I will use
Code (ags) Select
if (player.Room == 2)

Second thing I meant that I've already made a GUI with @SCORE@ text inside.
I used GiveScore(); in my script

I need to call a function that check if player has a certain score (let say > 50) then display text (EX. "Congratulations"), else if  < 50 display "Very Bad!"
Title: Re: Inventory+Player in room
Post by: Matti on Tue 25/11/2014 00:36:10
You don't need any function, just check the score like you'd do with any other variable.

Code (ags) Select

if (game.score > 50)..
else..
Title: Re: Inventory+Player in room
Post by: Gabarts on Tue 25/11/2014 09:21:59
Quote from: Matti on Tue 25/11/2014 00:36:10
You don't need any function, just check the score like you'd do with any other variable.

Code (ags) Select

if (game.score > 50)..
else..


Oh... I've made many tries with the text Label inside the GUI and some other variables, didn't know was this simple. Thanks