Thread: Readding eval()
View Single Post
  #27  
Old 03-23-2007, 05:47 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Inverness View Post
Maybe, it was a passing thought. Don't see how its much different that placing something in scripts folder.
Quests will work much better as their own object that manipulates the mudlib rather than a part of it.

My current use for eval() would be in my Dialog System, when a response to a topic is evaluated from the conditions of the response, a number of functions are allowed to be executed. For now it is only able to execute one function per script line.
PHP Code:
resp0.scriptcount=2
resp0
.script0=AddItem,50,gold
resp0
.script1=AddMsg,6,"You received 50 Gold coins." 
The functions AddItem and AddMsg are defined in the DialogControl as pfnAddItem() and pfnAddMsg(), the pfn meaning Parseable Function. And I have to translate all these functions to interact with the systems on Aeon, or whatever server will use the system.

Also there are the condition statements, which I would have loved if they could be evaluated, but since they're not I had to design the conditions object to load them into a format to be evaluated.

PHP Code:
resp0.conditionscount=1
resp0
.cond0=function,HasReadTopic,"arkland,",<,value,1,0,
Meaning: resp#.cond#=atype,avalue,aparams,comparator,btype, bvalue,bparams,or

If a condition could be evaluated from a script form using a function it would be alot easier to perform.
But as it is now, each part of the condition array is loaded into the condition object, and when the time comes to get the correct topic response for a player, eval() is called on the condition by the response object and this is calculated.
I am not certain if you need such a system why you do not just use multidimensional arrays and the for (temp.foo: temp.bar) iterator to go through each of your actions, so that you do not have to restrict yourself like you have currently done.
__________________
Skyld
Reply With Quote