Scripting language?

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


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.

Post Reply
Bear
Warrior
Warrior
Posts: 281
Joined: 01 Jul 2004, 19:09
Location: Computer
Contact:

Scripting language?

Post by Bear »

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 :D

seven posibilities to win, 1,1,1 ,2,2,2, ,3,3,3,...so on
the npc generates 3 random numbers.
User avatar
maci
Knight
Knight
Posts: 507
Joined: 05 Dec 2004, 20:01
Location: Germany
Contact:

Post by maci »

well for now we have squirrel on the server ..but i dunno if this what we going to use

http://squirrel.sourceforge.net/
ElvenProgrammer wrote:Maci: don't be rude, we're here to help people ;)
User avatar
Bjørn
Manasource
Manasource
Posts: 1438
Joined: 09 Dec 2004, 18:50
Location: North Rhine-Westphalia, Germany
Contact:

Post by Bjørn »

Yep, initial support for Squirrel is present now and we're still considering using Lua or Ruby. Little to no work has been done on figuring out how the scripts will actually interface with the engine, so this area is still rather unclear.
User avatar
maci
Knight
Knight
Posts: 507
Joined: 05 Dec 2004, 20:01
Location: Germany
Contact:

Post by maci »

we could develop some stuff to make it easier too

like npc generators and such things
ElvenProgrammer wrote:Maci: don't be rude, we're here to help people ;)
User avatar
nym
Novice
Novice
Posts: 116
Joined: 18 Aug 2004, 10:01
Contact:

Post by nym »

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]).
YOU ARE READING THIS!
User avatar
nym
Novice
Novice
Posts: 116
Joined: 18 Aug 2004, 10:01
Contact:

Post by nym »

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).

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);
}
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 :)
YOU ARE READING THIS!
User avatar
Bjørn
Manasource
Manasource
Posts: 1438
Joined: 09 Dec 2004, 18:50
Location: North Rhine-Westphalia, Germany
Contact:

Post by Bjørn »

An example of what the potion script could look like in Ruby:

Code: Select all

class Potion < Item
  def use(being)
    being.health += 10  # Increases health for target being
    destroy             # Destroys this item
  end
end
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.
User avatar
Bjørn
Manasource
Manasource
Posts: 1438
Joined: 09 Dec 2004, 18:50
Location: North Rhine-Westphalia, Germany
Contact:

Post by Bjørn »

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.

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>
Scripts would still be used to describe more complex things that the client need not know about in advance.
Blorx2
Novice
Novice
Posts: 60
Joined: 13 Mar 2005, 13:10
Location: Florence, SC

Post by Blorx2 »

Nym, I'd like to point out that in your code, "defense" is spelled wrong
"A wizard is never late, nor is he early, he arrives precisely when he needs to" - Gandalf
nayr
Novice
Novice
Posts: 57
Joined: 28 Jul 2005, 20:09

Post by nayr »

ruby! Ruby! RUBY! RRRRUUUUUBBBBYYYY!!!!!

Ruby is one of the best scripting languages. ever.
User avatar
nym
Novice
Novice
Posts: 116
Joined: 18 Aug 2004, 10:01
Contact:

Post by nym »

This is quite an old thread, but i will point out that Ruby will be used primarily for scripting on the server (although we won't rule out any other possibilities for alternate language support).
YOU ARE READING THIS!
Scooterman
Peon
Peon
Posts: 10
Joined: 18 Jul 2005, 01:29

Post by Scooterman »

Where i can find info about the current variables used in the server? Or some examples of working scripts? I?m really interested in helping developing scripts.

cya
User avatar
ElvenProgrammer
Founder
Founder
Posts: 2526
Joined: 13 Apr 2004, 19:11
Location: Italy
Contact:

Post by ElvenProgrammer »

Those are the scripts we're using at the moment on our server http://cvs.sourceforge.net/viewcvs.py/t ... -data/npc/
User avatar
criptos
Novice
Novice
Posts: 75
Joined: 20 Sep 2005, 16:00
Contact:

PHP :)

Post by criptos »

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.
May the Source be With You
Post Reply