OK, what I did was have the F8 key call a function that toggles the value of a variable, so that the value is either 0 or 1. Then in the action PlBiped01, I immediately use an "if" to check the value of the variable. If the value is 0, I call the action swim_mode; else I continue with the rest of the PlBiped01 code.

Here is the code that toggles the value of that variable:

Code:

var is_swim_mode_on = 0;

function toggle_swim_mode() {
beep;
if (is_swim_mode_on == 1) {
is_swim_mode_on = 0;
bipedPhy01_gravity = 9;
msg_show ("Fly mode is off", 5);
} else {
is_swim_mode_on = 1;
bipedPhy01_gravity = 0;
msg_show ("Fly mode is on: press Space to jump/move up, and 'c' to move down", 5);
}
}

on_f8 = toggle_swim_mode;



The code for the PlBiped01 action:

Code:
  
action PlBiped01
{
if (is_swim_mode == 1) {
swim_mode();
} else {
// the rest of PlBiped01 action code
}
}



I should point out though that the PlBiped01 action is a bit more complicated, because the first time it runs it sets up several threads to update the animation and the sound, and these threads continue to run until you remove the player entity. So in fact what I have above is only an example, and it does not apply cleanly to the PlBiped01 action. To do this properly, the toggling function has to remove the existing biped entity so that those extra threads stop, then create a new entity so that when the action is next invoked it can call swim_mode() cleanly without having those extra threads hanging around.

Last edited by TKN; 08/18/06 01:33.