If/else statements based on character room location

Started by Dannymac247, Sat 08/06/2013 07:07:01

Previous topic - Next topic

Dannymac247

My problem in a nutshell- I am trying to script an interaction with a room object that first checks if a particular character is in the current room, and then react accordingly. I post this hesitantly because I can't possibly be the first to want to do this, so I must be missing something on these boards, but I've been combing them and the manual for days and can't find the proper scripting language for it.

My larger problem- I suspect that the real issue is that, as a very inexperienced scripter, I don't even know what exactly I am looking for. I know what I want the game to do, I even have some clue of the logic I want it to use, (for instance, I have dabbled with the ADRIFT text game language and could accomplish what I am trying to do here fairly easily) I just am so new to the language that I am having trouble even searching for the command I want. I have found numerous links to AGS cheat sheets, which claimed to show the syntax of more or less every available command, but each link was broken. If anyone knows where such a cheat sheet can be found so I can start really learning the language, that would be much appreciated.

kconan

  Check the properties of the object in the room and you will see a field called "Interact Object", click on that you are taken to the function itself in the room code which is the name of the object followed by "_Interact".  In there you can add a line of code to check for the character.  So something like:

Code: AGS

function RoomObjectA_Interact()
{
  if (cDannysChar.Room == 1)
  {
    // Character is in room 1  
  }
  else
  {
    // Not in room 1
  }
}


  The player name is "cDannyChar" and object name is "RoomObjectA".

Khris

Dannymac247:
AGS comes with a helpfile, just press F1 in the editor.
There's also an online version: http://www.adventuregamestudio.co.uk/manual/

A character's room is a property of that character, so the first place to look is in the section Scripting -> Character functions and properties
http://www.adventuregamestudio.co.uk/manual/ags49.htm#Character.Room

Dannymac247

Thanks for the help, guys! Looks good so far.

SMF spam blocked by CleanTalk