Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Cubefiend on Tue 25/02/2014 04:09:55

Title: Room flavor text/ Bug in object selection... needs a fix!
Post by: Cubefiend on Tue 25/02/2014 04:09:55
Room flavor text seems easy enough but i'm not sure how to do it right.
basically once my object selection system is turned on and you press "E", a short description of the room would display and you would get a hint or something.

Bug in object selection... not so easy to fix (at least for me)
basically, if i don't have nine objects in my room and press a number that exceeds the number of objects in the room it gives me an invalid error code.
Not all of my rooms will obviously have nine objects so i'll need a fix. If anyone is asking for the code, the thread is here! (http://www.adventuregamestudio.co.uk/forums/index.php?topic=49785.0)
Title: Re: Room flavor text/ Bug in object selection... needs a fix!
Post by: Gilbert on Tue 25/02/2014 05:27:41
For the favour text part, one easy way to do that is to add a custom text property for Rooms and you can put different strings in different rooms.
Then use the Room.GetTextProperty() function to grab the String and display it.
(Quickly checking the manual revealed that the example code for this function does exactly this.)

Edit:
For the object part, I don't think this is a bug. It's the programmer's responsibility to check whether the number of objects is exceeded in a room. In fact, you can use the Room.ObjectCount property to check how many objects there are in the current room. So you may do something like:
Code (ags) Select

//Assuming index is an integer variable holding a certain number
if (index < Room.ObjectCount){ //valid object
  //Do something here
} else { //not a valid object
  //Do some other thing
}

Edit2:
I just checked the linked thread and KhrisMUC's codes already checked this limit, so does this still give you an error?
Title: Re: Room flavor text/ Bug in object selection... needs a fix!
Post by: Cubefiend on Wed 26/02/2014 03:09:26
Ah! Yeah. I just forgot to put the conditional for object count in my command statements (Looking and Interacting to be specific.) And I assume the Room.GetTextProperty() will work for my needs. Thank you!