Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (alibaba, 7th_zorro, AndrewAMD, 2 invisible), 1,030 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Load an entity with action #230138
10/03/08 02:43
10/03/08 02:43
Joined: May 2008
Posts: 123
B
BES Offline OP
Member
BES  Offline OP
Member
B

Joined: May 2008
Posts: 123
Is it possible to load an entity with an action already attached? ent_create allows you to assign an action defined in the loading level, but I'm hoping to be able to load an entity with an action defined in that entity's wed project and not in the loading project. In this way, I hope to store some data about the object that I am loading within itself. If there is another way to attach data to an object, please let me know!

Thanks so much for your time!

Re: Load an entity with action [Re: BES] #230151
10/03/08 09:27
10/03/08 09:27
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
in fact you cant "define" any actions on a wed project, you define them in your project, and let the wed know you defined some actions by attaching your script to your map.(we re doing this because we want see our actions in behaviour list wink )

when you press run from wed it runs the script not the level.(try adding a short script that doenst even loads your level or that loads another level)

Last edited by Quadraxas; 10/03/08 09:28.

3333333333
Re: Load an entity with action [Re: Quad] #230384
10/05/08 07:19
10/05/08 07:19
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
While he's technically correct, this can be surpassed, what I do is create a function that has all of the actions I want predefined as integer values, and pass those values to the function, the function from there simply translates what I'm sending to it and creates actions from it.

For an example (I know I murdered the explanation)
Code:
#define action1 1
#define action2 2
#define action3 3

main()
{
    ENTITY* aPointer;
    //specifying a pointer allows you to send it/manipulate it later in this or other functions
    aPointer = spawnFunction(action1);
}

//Usually I'd specify 2 or 3 variables for the vector in 
//order to place it where you want but it's really up to you.
ENTITY* spawnFunction(int action)
{
    if(action == action1)
    {
       ent_create("default.mdl", vector(0, 50, 100), yourAction1);
    }
    else if (action == action2)
    {
       ent_create("raptor.mdl", vector(0, 50, 100), yourAction2);
    }
    else if (action == action3)
    {
       ent_create("tower.mdl", vector(0, 50, 100), yourAction3);
    }
    else
    {
        //you could write an error, or whatever here, it's good practice to use error checking
    }
    return my;
}

//Usually defined somewhere else, like another file
action yourAction1()
{
...
}
action yourAction2()
{
...
}
action yourAction3()
{
...
}


Last edited by Trooper119; 10/05/08 07:19.

A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Load an entity with action [Re: Trooper119] #230573
10/06/08 19:16
10/06/08 19:16
Joined: May 2008
Posts: 123
B
BES Offline OP
Member
BES  Offline OP
Member
B

Joined: May 2008
Posts: 123
Thanks, both of you. I think I have to use a different means to accomplish my purpose (load a config file probably). In retrospect it didn't make much sense to think I could run code not compiled with the loading project.

Cheers!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1