Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-18-2006, 08:27 AM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
Question 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.
__________________
Reply With Quote
  #2  
Old 07-18-2006, 08:29 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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-
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #3  
Old 07-18-2006, 08:36 AM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
Got it to work!
Anyways, I'll leave this here so others can see how to do it.

ironically the code I posted worked.
__________________
Reply With Quote
  #4  
Old 07-21-2006, 03:27 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 07-22-2006, 01:21 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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. >_>
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #6  
Old 07-23-2006, 04:23 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
that idea sounds unexpectedly useful for debugging.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:12 PM.


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