Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: EnterTheStory (aka tolworthy) on Fri 13/06/2008 21:44:32

Title: how to tell if a character is tinted? [SOLVED]
Post by: EnterTheStory (aka tolworthy) on Fri 13/06/2008 21:44:32
character.RemoveTint will crash a game if called when a character has no tint (in 2.72). Is there any way to tell if a character is tinted?

Or a way to test if RemoveTint will crash the game, then not run it (like testing for null or something)?
Title: Re: how to tell if a character is tinted?
Post by: Khris on Fri 13/06/2008 22:06:07
// script header
import function Tnt(this*Character, int red, int green, int blue, int saturation, int luminance);
import function RemTnt(this*Character);

// global script

int tinted[];

tinted = new int[Game.CharacterCount];  // this line inside game_start!

function Tnt(this*Character, int red, int green, int blue, int saturation, int luminance) {
  tinted[this.ID] = true;
  this.Tint(red, green, blue, saturation, luminance);
}

function RemTnt(this*Character) {
  if (!tinted[this.ID]) return;
  this.RemoveTint();
  tinted[this.ID] = false;
}


EDIT: removed redundant export line.
Title: Re: how to tell if a character is tinted?
Post by: EnterTheStory (aka tolworthy) on Fri 13/06/2008 22:24:46
Thanks!
[edit after trying it:]

So basically there is no internal way to tell if a character is tinted. So we need to keep a record every time 'tint' is used. Fair enough.
Title: Re: how to tell if a character is tinted? [SOLVED]
Post by: Khris on Fri 13/06/2008 22:43:09
Correct, afaik. I guess a Character.Tinted property sounds like a reasonable request though.