Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   dynamic function calling (https://forums.graalonline.com/forums/showthread.php?t=67420)

calani 07-18-2006 08:27 AM

dynamic function calling
 
Okay, I'm trying to do something, and I'm not sure if its supported by GS2 or not.

I'm trying to redo my system in such a way that I can call any function from chat or suchlike without having one gigantic switch and hardcoding each functioncall.

Basically, I'm trying to do this:

PHP Code:

function callfunc(temp.funcname,temp.fparams) {
  
temp.fparams=replacemarkers(temp.fparams);  // replace escapes with values
  
(@temp.funcname)(temp.fparams);  // call the function
}

function 
prop(temp.fparams) {
  
do_stuff();


This way I could call a showimg, setfocus, local functions, etc.
I'm going to add in a preset sys that lets me do preset action (or set new ones) to keys. as an example, lmouse="gani $ sit 0" would call a local gani() function with the params "$m jellybean blue.png". (I use $m as an escape that refers to the current mousetarget. others are $mx $my for mouse xy, etc)


Problem I'm having - this just doesn't work.

ForgottenLegacy 07-18-2006 08:29 AM

Make sure temp.funcname is set to 'prop'. Maybe do an echo to figure out what it is set to. It works for me in DBs. -Tests it in a weapon-

calani 07-18-2006 08:36 AM

Got it to work!
Anyways, I'll leave this here so others can see how to do it.

ironically the code I posted worked.

ApothiX 07-21-2006 03:27 AM

Just a suggestion: There is no need to use the temp. prefix for function parameters. Parameters are defaulted to the same attributes as temp.variables.

ForgottenLegacy 07-22-2006 01:21 AM

Quote:

Originally Posted by ApothiX
Just a suggestion: There is no need to use the temp. prefix for function parameters. Parameters are defaulted to the same attributes as temp.variables.

Even with no prefix they act like 'temp.' vars? Odd. I thought the prefix meant everything about the lifetime of the variable. Anyway, I do it because it keeps my scripts neat. I dislike any variables without prefixes. >_>

jake13jake 07-23-2006 04:23 PM

that idea sounds unexpectedly useful for debugging.


All times are GMT +2. The time now is 12:09 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.