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
1 registered members (Ayumi), 1,088 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Call function with STRING or function array? #353641
01/11/11 23:26
01/11/11 23:26
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
hi

i have a problem as always laugh

I just want to know if it is possible to have function arrays. Cause i want to call function from a spell list or better id. I send an id and the correct spell function is started.

Instead of
Code:
Heal(caster, cast_target, random_add);



i want something like
Code:
spell_id(caster, cast_target, random_add);



Is it possible in any way?

Re: Call function with STRING or function array? [Re: Rasch] #353643
01/11/11 23:32
01/11/11 23:32
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
What do you want to do?! Neither of your examples is an array of function pointers.
While basically there is no problem having a bunch of pointers in an array which points to functions (thats what you do when you call a function, you jump to another code address and continue execution from there), you seem to have no idea so you might want to stick with something else.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Call function with STRING or function array? [Re: Rasch] #353645
01/11/11 23:33
01/11/11 23:33
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
Is this what you're looking for?
http://www.conitec.net/beta/engine_getscript.htm

Re: Call function with STRING or function array? [Re: Saturnus] #353646
01/11/11 23:46
01/11/11 23:46
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
yes it is. but itīs not working. What i mean is instead of writing Heal(...) i want to for example take a string that hold "Heal" inside and place that string before the (...)

STRING* spell_id = "Heal";

spell_id(...)

But that doesnt work.

Re: Call function with STRING or function array? [Re: Rasch] #353648
01/11/11 23:55
01/11/11 23:55
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Obviously it does not. Its a string, not a function wink
Look into saturnus link, it will help you.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Call function with STRING or function array? [Re: WretchedSid] #353650
01/12/11 00:04
01/12/11 00:04
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
I got it. Never done it before with function pointers. That was easy just didnt understand what exactly i have to write.

Thanks

Re: Call function with STRING or function array? [Re: Rasch] #353691
01/12/11 10:28
01/12/11 10:28
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Ok another problem. If iīm writing

engine_getscript("Heal");

The spell is found.

If i use a STRING that contains "Heal" itīs not finding anything. I want something like this. Maybe it has to be a char? But that also didnt work.

STRING* spell_type = "Heal";
engine_getscript(spell_type);

Re: Call function with STRING or function array? [Re: Rasch] #353693
01/12/11 10:53
01/12/11 10:53
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
STRING* spell_type = "Heal";
change to
STRING* spell_type = str_create("Heal");

Re: Call function with STRING or function array? [Re: MrGuest] #353703
01/12/11 13:51
01/12/11 13:51
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Are you sure? I cant test it at the moment but if i use the first method its a string with content.

I think str_create would be for String Arrays like..

STRING* spell_type[3];
spell_type[0] = str_create("Heal");
spell_type[1] = str_create("Fire");
spell_type[2] = str_create("Ice");

But thats the same cause if i give out my string with error(spell_type) it says correctly Heal.

Maybe it needs another input in the brackets?

eedit: ok i got it

engine_getscript(_chr(spell_type));

made it laugh

Last edited by Rasch; 01/12/11 21:58.

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