Possible to return an " action " name to a " STRING* " ?

Posted By: Enduriel

Possible to return an " action " name to a " STRING* " ? - 06/04/09 18:58

Hello devteam!

I have a small problem, I'm working on my own in-game editor for an RPG where I can control the events and conversations through it.

But to save out my own "level" files I need to somehow return an "action" name assigned to an entity to a " STRING* ".
Example: If player has action act_player(), then I want to return it to STRING* str_temp so it contains "act_player".

Is there a way to do this? If not, could it be implemented as I really need this?

Thanks in advance!
Posted By: EvilSOB

Re: Possible to return an " action " name to a " STRING* " ? - 06/04/09 20:09

I dont know how managable that would be, because its possible, and quite common, for an entity to have multiple
actions attached to it at the same time. How could that be handled?

You say its in YOUR editor right?
So are YOU(or your code at least) assigning the actions to the entities?
If so, when you assign the action, cant you save the action name into a spare skill of that entity at the same time?
Say, at the start of the action itself?
eg
Code:
action player_act()
{
   wait(1);
   my.skill25 = str_create("player_act");
   ...

Posted By: Enduriel

Re: Possible to return an " action " name to a " STRING* " ? - 06/04/09 20:55

Right now, when I right click ---> add model in my own editor, it just creates the chosen model with ent_create, and assigning NULL as an action.

So basicly, what I need is assigning an action after it has been created. What I came up with is whenever I assign a NEW action to the entity in the editor, I just store its flags, skills, pos etc and then ent_remove(selected), and then recreate it with the chosen action with ent_create to see the change in real-time.

But I had trouble returning the action name to a string for saving purposes. Your method will work and is same as what Slin suggested, though it also needs typecasting ^^, I could use skill[99] for it ^^

But is there a way maybe through some engine commands to return it? Otherwise I guess I'll have to spend a skill :P

Thanks for the help btw laugh appreciated! I'll still wait a dev to answer this post though!
Posted By: jcl

Re: Possible to return an " action " name to a " STRING* " ? - 06/05/09 09:20

The action name can't be returned because the action is nowhere stored in the entity. An entity action is just a normal function with the only exception that the "me" pointer is set to that entity.

What I could do is implementing a function that returns a name for a function address, f.i.

char* name = engine_getfunctionname(player_act);

Would that help?
Posted By: EvilSOB

Re: Possible to return an " action " name to a " STRING* " ? - 06/05/09 10:04

For me, that does actually sound useful... Yes please.

Also please a matching function that returns the address of a function given by name. F.I
long act_addr = engine_getfunctionAddr(player_act);
(assuming one doesnt already exist, I havent looked)

Posted By: Enduriel

Re: Possible to return an " action " name to a " STRING* " ? - 06/07/09 18:03

i've noticed that using shift+F11 displays the action name in the watched string, wouldn't this suggest that the action string already exists?

many thanks
Enduriel

Example:


Posted By: Quad

Re: Possible to return an " action " name to a " STRING* " ? - 06/07/09 18:34

maybe, maybe not. afaik shift+f11 panel and ctrl+f11 views are not lite-c code. it's implemented in the engine itself.

but ofc, that nay give some hints to JCL
Posted By: jcl

Re: Possible to return an " action " name to a " STRING* " ? - 06/08/09 07:00

The engine displays the action name by checking all currently running actions and finding in which one "me" is the entity pointer. This is not necessarily the original entity action. You can make any function to an action by setting the "me" pointer.

But I'll implement the engine_getfunctionname function. The reverse function is already there.
© 2023 lite-C Forums