
Okay, so I'm playing around with a little mini-mod and I have a little problem with a touch function. Basically, I'm using a yellow platform (in the form of a model) which turns red when you step on it, and (I would hope) stays red (and solid) when you stand on it, but then becomes transparent (and non-solid) when you stop touching it (in other words, when you step on another platform).
For some reason, I can't get the platform to remain solid as long as the player is standing on it.
This is the code:
.float touched;
.float touchytime;
.float alpha;
void() platform_touch =
{
if (self.touched == 0)
{
if (other.health > 1)
{
bprint("first touch");
self.skin = 1;
self.touched = 1;
sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
}
}
if (self.touched == 1)
{
if (other.health > 1)
{
self.touchytime = time + 5;
bprint("constant touch");
}
}
};
void() platformthink =
{
self.touch = platform_touch;
if (self.touched == 0) self.touchytime = time + 1;
if (self.touched == 1 && (self.touchytime + 5) < time)
{
self.alpha = 0.4;
self.solid = SOLID_NOT;
}
self.think = platformthink;
self.nextthink = time + 1;
};
void() item_armor1 =
{
self.touch = platform_touch;
precache_model ("progs/armor.mdl");
setmodel (self, "progs/armor.mdl");
self.skin = 0;
setsize (self, '-64 -64 0', '64 64 20');
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_FLY;
self.think = platformthink;
self.nextthink = time + 1;
self.touchytime = time + 1;
};
I'm using the armor as the platform, as you can see. I know I could just make a new entity but, well, it does not make any difference since the mini-mod won't be using armors.
The weird thing is that I also never get my bprint messages, even though I do hear the sound when I step on a new platform and it does turn red (skin = 1). I have the feeling that there is something really simple that I'm missing, but I don't know what it is... Do you have suggestions?
Oh, and, when I continuously jump on the platform, it looks like the turning into non-solid takes longer...
