Room flavor text/ Bug in object selection... needs a fix!

Started by Cubefiend, Tue 25/02/2014 04:09:55

Previous topic - Next topic

Cubefiend

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!
lauren merchant's magical adventure!

Gilbert

#1
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

//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?

Cubefiend

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!
lauren merchant's magical adventure!

SMF spam blocked by CleanTalk