Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,382 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Synonyms and on_ instruction... #3696
05/17/01 02:04
05/17/01 02:04
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
Hi, this is probably a stupid question that belongs in the Beginner's section - sorry if so:

I am tying to get more than one entity to access and use one function by using the on_[key] instruction. The reason I'm doing this is that I'm testing out the basics of a two player fighting game. The basic structure of my code is this:

function do_this{
if(my._suchandsuch==this)
{my._something=this;}
blahblah();}

action character1
{on_a = do_this;}

action character2
{on_b = do_this;}

(I could post the real code but it wouldn't help, as it's just calling specific animation data at the moment.)

Theoretically, when character1 calls do_this (by the player hitting the 'a' key), the MY synonym in do_this should become character1; and the same goes for character2 (on the player pressing the 'b' key). However, instead, if I try to press the 'a' or 'b' keys I get an empty synonym error message. It works fine if I assign a synonym to the characters (eg player=me;_ and then do the same at the beginning of the do_this function (eg. me=player , but if I do this then I need to create a separate do_this function for each character. This might not be so bad, except that I intend for there to be more AI characters that will access the same function...

I've searched all the posts on the forum, and from what I've read I think it might be that the on_ instruction doesn't send the synonym with it, but just executes the function. Is this the case? If so, does anyone know how I can get around this, so that both entities can access the function?
Thanks, sorry for the dumb question.
-Keith


Re: Synonyms and on_ instruction... #3697
05/17/01 02:15
05/17/01 02:15
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
I should add that I am at the moment using this workaround:

function p1_do_this{
me=player1;
do_this():
}

function p2_do_this{
me=player2;
do_this;
}

function do_this{
blah blah;}

action character1{
player1=me;
on_a = p1_do_this;
}

action character2{
player2=me;
on_b = p2_do_this;
}

Really I just wondered if there was a simpler way of doing this, without the intermediary steps...


Re: Synonyms and on_ instruction... #3698
05/18/01 00:05
05/18/01 00:05
Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
W
WildCat Offline
Expert
WildCat  Offline
Expert
W

Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
Ambit,
I also discovered the problem you are having, and I pretty much did what you are doing to get around it.

If anyone else found a better way, I'm interested too.

-WildCat



Visit us at [url=http://www.vertexgames.com]Vertex Games[/url]!
Re: Synonyms and on_ instruction... #3699
05/19/01 03:39
05/19/01 03:39

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Hi all!

Yes, that is a problem. It seems that you can just assign a function without a parameter to a key or an event, e.g.

on_p = do_this;

And NOT

on_p = do_this(7);

That's a pity but it might explain why there are almost no functions in the templates (at least I found none so far) which works with a parameter...

If anyone finds a way to workaround this without defining a function for each call like it was done in the posting, please tell.

Gnometech


Re: Synonyms and on_ instruction... #3700
05/22/01 22:50
05/22/01 22:50

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Using a global variable is another workaround, but not much better :
Var do_this_param = 0;

FUNCTION do_this(param){ ...}
FUNCTION do_this(){ do_this(do_this_param)}
...
on_p = do_this;
...
do_this_param = 7 ; // change whenever needed

Btw, I think there are so few functions in the templates, because the templates are
only updated/extended, but not rewritten (but thats ok for me)


Re: Synonyms and on_ instruction... #3701
05/22/01 23:26
05/22/01 23:26

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Or perhaps you can do something with the :

"New features implemented in A5 engine 5.05: (-> bugs&features)
str_for_entname(string,entity);
str_for_entfile(string,entity);
Sets the string to the WED name or to the file name of the given
entity.

syn_for_name(string);
returns the synonym of the entity with the given WED name. Names can
be assigned to entities through [Properties] in WED. This way,
entities placed in a level can now be accessed in WDL actions.
Example:... "

...but I haven't used them yet, so it's just an idea...



Moderated by  HeelX, Spirit 

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