WED [Need help understanding/creating actions]

Posted By: DarkProgrammer

WED [Need help understanding/creating actions] - 05/19/14 22:13

I hope this is the correct forum to post this, if not, I apologize & someone please let me know where this post belongs?

I am new to Gamestudio & Lite-C programming.

Ok so here is what I need help understanding. I'm following along with the online tutorials/Lite-C workshops.

The first point I need help understanding is in

"Workshop 10: Actions"

In that lesson there is a 3D model of a jet plane rotating inside a hangar. now as I understand the model of the jet was placed in the scene using the WED editor. what I don't understand is how the code in the SED is actually causing the model to rotate. This is the code from the editor:

Code:
action rotate_plane()
{
    while (1)
    {
        my.pan = my.pan + 0.1;
        wait (1);
    }
}



The question is how is this linked to the 3D jet model? where is my.pan defined? It doesn't seem to be linked to the 3D model in any way.


My next question has to do with "Workshop 11: Pointers"

There are 2 wizard models in the scene, each assigned to their own actions, in the text of the lesson, it says the actions are assigned in the WED editor, how do I view those actions in WED and also how can I change the names of the actions or create my own new actions?

Any help and advice would be greatly appreciated. so thank you for reading this and offering your advice.
Posted By: Superku

Re: WED [Need help understanding/creating actions] - 05/19/14 22:29

The concept is pretty simple:

You (can) build your level(s) in WED. The "Map Properties" allow you to attach a (single) script to your level, usually your main script. WED will now scan that script automatically for functions called "actions" so they will appear in the action selection on the "Behaviour" tab next to the "Properties" tab which appears on the left side of the vertical toolbar when you click an entity. (This means that you can and have to change your action names there, i.e. in SED/ the script file.)

Your quoted action realizes a framerate dependent rotation around the z-axis because that is what pan does: http://www.conitec.net/beta/aentity-pan.htm
For more information, open (for example) the online manual and search for Engine Objects (and then ENTITY).

my (and you) are pointers that each function (usually only with actions) can use to manipulate certain entities. When you now assign rotate_plane to one or multiple entities in your level, the action will be started on level initialization (immediately after level_load) and the my-pointer will be assigned to each appropriate entity and saved and restored by the function scheduler (or similar) each frame.
Posted By: DarkProgrammer

Re: WED [Need help understanding/creating actions] - 05/19/14 23:40

Superku thanks for your quick reply. in your post you said:

"WED will now scan that script automatically for functions called "actions"..."

Did you mean SED in that sentence?

Thank you again.
Posted By: Superku

Re: WED [Need help understanding/creating actions] - 05/19/14 23:56

No, WED was not a typo.
As I've stated in my post above you can attach actions in WED via the Behavior tab. Somehow WED needs to know what kind of actions you have at your disposal. For that reason WED automatically keeps track of your script files and when you update them and WED will generate a new list of available actions then.

Are you having any problems with that process in particular?
Posted By: DarkProgrammer

Re: WED [Need help understanding/creating actions] - 05/20/14 00:00

Thank you, so, in other words, I have to define the name of the action in SED. then WED will attach them to the model/object?
Posted By: DarkProgrammer

Re: WED [Need help understanding/creating actions] - 05/20/14 00:08

So here is a specific example. This is from the Workshop 11 on pointers.

I'm playing around with the code & I want to define my own actions for the wizard models that were created with WED. How do I change the names of the actions that are defined in the script? or define new actions for the models? Those are my specific questions.

I want to rename the actions "wizard_with_pointer()" & "wizard_simple()"


Code:
#include <acknex.h>
#include <default.c>

ENTITY* wizard1;
ENTITY* wizard2;

function move_up()
{
  wizard1.z += 5;
}

function move_down()
{
  wizard1.z -= 5;
}

function main()
{
  level_load ("work11.wmb");
  on_u = move_up;
  on_d = move_down;
}

action wizard_with_pointer()
{
  wizard1 = my;
  my.ambient = 100;
}

action wizard_simple()
{
  wizard2 = my;
  my.ambient = 100;
}

Posted By: Superku

Re: WED [Need help understanding/creating actions] - 05/20/14 00:14

I can only guess what your problem is right now, sorry. Please do the following:

1) Create a new level in WED, for instance a large hollowed cube, and save it.
2) Open the folder of the file, create a new text document, call it for example rotategame.c, fill it with the following content, add/ replace the appropriate level name and save it.
Click to reveal..
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

void main()
{
	fps_max = 60;
	level_load("your level name here.wmb");
}

action rotate_pan()
{
	while (1)
	{
		my.pan += time_step;
		my.pan %= 360;
		wait (1);
	}
}

action rotate_tilt()
{
	while (1)
	{
		my.tilt += time_step;
		my.tilt %= 360;
		wait (1);
	}
}


3) Go to Map Properties with your newly created level opened, then attach rotategame.c as the main script.
4) Add two entities to the room and attach one of the actions each.
5) Build your level, run the script (and press [0] to move the camera freely), watch the two entities rotate.
6) Now try to add a third action to the script, rotate_roll (that rotates "my" around roll).
7) Add a third entity and attach that new action.
8) Build, run and observe.

Does that clarify your issue/ question? If not, please state the step where things don't seem to work out.
Posted By: Superku

Re: WED [Need help understanding/creating actions] - 05/20/14 00:15

How to change an action name? Just edit it, type whatever you want, there are barely any rules or restrictions for action names.
If you have already assigned one or more of those actions in WED you now need to assign the new changed ones again.
Posted By: DarkProgrammer

Re: WED [Need help understanding/creating actions] - 05/20/14 00:59

Originally Posted By: Superku
How to change an action name? Just edit it, type whatever you want, there are barely any rules or restrictions for action names.
If you have already assigned one or more of those actions in WED you now need to assign the new changed ones again.


Sorry to keep asking all these questions....

Where do I edit the action name..,in WED or SED? also when you say assign, again do you mean in SED or WED?


Also, I'm going to try the example you provided, I'll let you know the results.

Thanks so much for taking the time to answer my questions.
Posted By: DarkProgrammer

Re: WED [Need help understanding/creating actions] - 05/20/14 12:34

Superku, The code worked, thank you very much for the help. You really cleared up the issues for me. Just 1 last thing... the methods my.pan & my.rotate, I assume they are built in functions of entities/models?
Posted By: Superku

Re: WED [Need help understanding/creating actions] - 05/20/14 12:42

Originally Posted By: Superku
Your quoted action realizes a framerate dependent rotation around the z-axis because that is what pan does: http://www.conitec.net/beta/aentity-pan.htm
For more information, open (for example) the online manual and search for Engine Objects (and then ENTITY).
© 2024 lite-C Forums