actions in your script

Posted By: MDC

actions in your script - 07/26/06 11:06

How do i put knew actions in my script, like where exactly do i write them or just anyway. give detail. im kinda slow.
Posted By: aztec

Re: actions in your script - 07/26/06 11:31

this is very simple you just define actions this:

action simple
{



}

thats a simple definition dont place the actions before the function main (its just my tip) you can give moddels or perfabs action in WED just click at them properties and then youŽll see all the actions you wrote
I hopw this helps you
Regards
Aztec
Posted By: MDC

Re: actions in your script - 07/26/06 12:27

i did that my action wasnt there when i tries to put it in.
Posted By: EpsiloN

Re: actions in your script - 07/27/06 21:16

after you write the action in your script file you have to re-open your level or to reload your script file ... it doesnt update the action list if you dont do this...
Posted By: Frits

Re: actions in your script - 07/28/06 06:33

In WED;
File-->Preferences-->Tab Advanced
Set 'Reload of externally modified files'to Auto.

Regards,
Frits
Posted By: TKN

Re: actions in your script - 08/03/06 04:55

Is there a way to switch actions using c-script commands? For example I want pressing F8 to toggle between action PlBiped01 and action player_swim, even though by default the level should start with the player using action PlBiped01 (so I set that action in the Behaviour panel for that entity in WED).
Posted By: aztec

Re: actions in your script - 08/03/06 08:07

Yes I think its possible you can use handles or entities I think
entity* action;
entity* action2;
action 1
{
if(F8 != pressed)
{
action = me;
rest of action...
}
}

action 2
{
if(F8 == pressed)
{
action2 = me;
rest of action
}

But i dont know If it works I think it wont but at least I tried
maybe learn a bit more about handels I think
Posted By: TKN

Re: actions in your script - 08/18/06 01:28

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.
Posted By: vlau

Re: actions in your script - 08/18/06 13:27

You should place your codes inside a while-loop, otherwise
it never call swim_mode() even is_swim_mode == 1.

Code:

action PlBiped01
{
while(my != NULL)
{
if (is_swim_mode == 1)
{
swim_mode();
} else {
// the rest of PlBiped01 action code
}
wait(1);
}
}


Posted By: TKN

Re: actions in your script - 08/25/06 03:31

Actually there is no need to add the while loops you mention, because the swim_mode() function and the part that I referred to as "the rest of the PlBiped01 action code" each set up their own threads and while loops. If you look at the template scripts PlBiped01.wdl and move.wdl and movement.wdl you can see the two actions yourself (swim_mode and PlBiped01).
© 2024 lite-C Forums