how to tell if a character is tinted? [SOLVED]

Started by EnterTheStory (aka tolworthy), Fri 13/06/2008 21:44:32

Previous topic - Next topic

EnterTheStory (aka tolworthy)

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

Khris

#1
Code: ags
// 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.

EnterTheStory (aka tolworthy)

#2
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.

Khris

Correct, afaik. I guess a Character.Tinted property sounds like a reasonable request though.

SMF spam blocked by CleanTalk