mud progs

Posted by Gohan_TheDragonball on Thu 14 Sep 2006 12:08 AM — 5 posts, 20,106 views.

USA #0
I recently completely redid the script system in smaug, and I was implementing a new mining script when I realized that programs didn't run exactly as I thought they did, and I need to change them.

Basically as it is, progz are stored in the mob_index_data structure, I would like to move them into the char_data structure. This way each mob would have its own instance of the program in its data structure, and if something is modified like a variable on the prog it would only affect the programs on that mob, and not the whole base set. I would just like to see if anyone else has done this or attempted this, and if they know of or see any potential problems with redoing the system this way.

Why I want to do this, in this example, I have mobs that are miners, and the scripts control what action they are currently doing. A variable in the program structure controls what script is running in a particular group, for this instance lets say the script that governs the mining of ore is running. The system currently would have EVERY miner of the specific mob vnum doing that action at the same time.

Any info or insight would be appreciated.
Australia Forum Administrator #1
Personally I would convert the mob progs to Lua, but perhaps that is going too far? ;)
USA #2
i'll put that in the maybe pile :)
USA #3
A few years ago, I wrote my own scripting language for my MUD that is basically a (simple) fully-featured language with full control flow, functions, etc. to replace MUD script. I solved the variable problem by storing a separate instance of the symbol table (that maps variable names to variable values) on each instance of a thing that has a script on it, as soon as the values become different. This helps save memory, by not needlessly duplicating symbol tables.

Similarly, all instances shared the script itself with their prototypes, unless an instance had the script changed.

Of course, if I were to redo this, I would without a doubt use Lua instead. Lua is incredibly easy to embed in an application, and all the work that would go into exposing functions to a home-grown language would be basically the same for exposing functions to Lua.
USA #4
well i already introduced a variable system into my mud progs, some snippet i found for smaug that i redid to suit my needs. i also developed a small way to make/call functions:

$f.rand(20,40)

setvar $n 1 <string>
if str($n) == $n.var1
if str($n) == $f.rand(20,40)

stuff like that

of course the system is slightly limited, but it works for my current needs.

if you want to see the system i redid as well as the redid version of the prog variables stuff i uploaded it to mudbytes.net not too long ago. i would love some comments/insight on it.

http://www.mudbytes.net/index.php?a=files&s=viewfile&fid=740