Scripting language?
Forum rules
This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.
Its current use is for the continued development of the server and game it has always served: TMW Classic.
Scripting language?
what scripting language would we be using for TMW? I personaly like athena scripting code, but that is because iv been working with it for some time... but im just wondering what type of scripting language we will be using?
BTW, i made a slot machine npc
seven posibilities to win, 1,1,1 ,2,2,2, ,3,3,3,...so on
the npc generates 3 random numbers.
BTW, i made a slot machine npc
seven posibilities to win, 1,1,1 ,2,2,2, ,3,3,3,...so on
the npc generates 3 random numbers.
well for now we have squirrel on the server ..but i dunno if this what we going to use
http://squirrel.sourceforge.net/
http://squirrel.sourceforge.net/
ElvenProgrammer wrote:Maci: don't be rude, we're here to help people
Yeah, currently Squirrel is being used as a "sandbox" scripting language for testing. But by no means will be be the only language available on TMW server (the language of choice will be compiled into TMW server via defines, or possibly we could have multiple scripting environments chosen at runtime). A Ruby binding would exist now if i could find some decent documentation on it (i haven't been able to find good embedding documentation, if you know of any [which do not use SWIG] give me a shout ).
While i am only using Squirrel for testing at the moment, it could might as well replace Lua, as Squirrel is a Lua clone with _many_ similarities.
The way i currently think scripting would work is this (most actions will be deferred from server into scripting, only having the server do essential tasks and provide an interface to the scripts). So each Being, Skill, etc. will have their actions executed by a script (and the server will provide a necessary means to do so). By doing this we should have a highly extensible server (and by deferring many tasks into higher-level scripting realm we should hopefully have a more secure server [buffer overflows less feasible etc]).
While i am only using Squirrel for testing at the moment, it could might as well replace Lua, as Squirrel is a Lua clone with _many_ similarities.
The way i currently think scripting would work is this (most actions will be deferred from server into scripting, only having the server do essential tasks and provide an interface to the scripts). So each Being, Skill, etc. will have their actions executed by a script (and the server will provide a necessary means to do so). By doing this we should have a highly extensible server (and by deferring many tasks into higher-level scripting realm we should hopefully have a more secure server [buffer overflows less feasible etc]).
YOU ARE READING THIS!
If you are interested in looking at Squirrel, check out squirrel.sf.net . I have worked a little on the scripting system and currently here is what an item script will look like (this is still in the design/testing phase, so it will most likely change a bit).
The item, as you may have guessed (or read) is a potion. Each different type of script will have a library of functions available to use (there will also be a standard library which will consist of all the common functions). Also note that certain types of items will not require all the variables to be defined (many defined above are for illistration purposes only).
Currently the scripts dont do alot, as what they are supposed to control hasn't been implemented fully (i am starting the scripting early to allow total integration of scripting into the server to allow maximum customizability).
The way the scripts work is:
a) the script is compiled
b) the main body of the script is executed (everything which can be executed)
c) the script finishes running, leaving the registered variables in memory.
d) the special functions defined are called for their appropriate action.
The name <- value; syntax is the "new slot in root table" operator, which creates a global variable which will persist until the virtual machine is destroyed.
EDIT: Any suggestions appreciated
Code: Select all
// Define required variables
name <- "Potion";
type <- 0;
attack <- 0;
defenst <- 0;
luck <- 0;
vitality <- 0;
//
function use()
{
print("Item " + name + " was used\n");
setHealth(getHealth() + 10);
}
Currently the scripts dont do alot, as what they are supposed to control hasn't been implemented fully (i am starting the scripting early to allow total integration of scripting into the server to allow maximum customizability).
The way the scripts work is:
a) the script is compiled
b) the main body of the script is executed (everything which can be executed)
c) the script finishes running, leaving the registered variables in memory.
d) the special functions defined are called for their appropriate action.
The name <- value; syntax is the "new slot in root table" operator, which creates a global variable which will persist until the virtual machine is destroyed.
EDIT: Any suggestions appreciated
YOU ARE READING THIS!
- Bjørn
- Manasource
- Posts: 1438
- Joined: 09 Dec 2004, 18:50
- Location: North Rhine-Westphalia, Germany
- Contact:
An example of what the potion script could look like in Ruby:
Whether we go with class or instance methods depends on wether we want to allow the scripts to hold additional item state information. This affects the way we'd store/retrieve item instances from the database and general item management. The above example defines an instance method.
Code: Select all
class Potion < Item
def use(being)
being.health += 10 # Increases health for target being
destroy # Destroys this item
end
end
- Bjørn
- Manasource
- Posts: 1438
- Joined: 09 Dec 2004, 18:50
- Location: North Rhine-Westphalia, Germany
- Contact:
Hmm thinking about this idea it occured to me specifying item usage effects in scripts is probably not the best thing to do. This is because not only will the server need to execute it but the client will also need to be able to display to the user what the effects of using the item are beforehand. Hence a more fixed XML approach example now, which we should probably evaluate and prototype a lot before implementation.
Scripts would still be used to describe more complex things that the client need not know about in advance.
Code: Select all
<item id="16" name="Potion" value="200" ...>
<use target="self">
<effect type="heal" duration="0" amount="10"/>
</use>
</item>
<item id="55" name="Helm of the bear" ...>
<equip>
<effect type="armor" amount="2"/>
<effect type="strength" amount="10"/>
</equip>
</item>
-
- Peon
- Posts: 10
- Joined: 18 Jul 2005, 01:29
- ElvenProgrammer
- Founder
- Posts: 2526
- Joined: 13 Apr 2004, 19:11
- Location: Italy
- Contact:
Those are the scripts we're using at the moment on our server http://cvs.sourceforge.net/viewcvs.py/t ... -data/npc/
PHP :)
There a good amount of documentation to make a php binding to a c++ lilbrary...
And also, you could have all the other php functionality, for example, NPC using scripts could access database by they?re own and check things at the database stats...
I belive ruby could do the trick, but I?ve reading about themana world for a week, and I really have found little information about ruby compared to php...
Just a tougth.
And also, you could have all the other php functionality, for example, NPC using scripts could access database by they?re own and check things at the database stats...
I belive ruby could do the trick, but I?ve reading about themana world for a week, and I really have found little information about ruby compared to php...
Just a tougth.
May the Source be With You