editing items and weapons

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

editing items and weapons

Post by zoom »

Hi

I am interested in how item creation works .
(I do not have windows installed, so I am not able to play dsb)

Is there an editor?
If so , should I use the syntax provided in the dsb function /lua tutorial thread? How/where?

Most importantly , how far are those powers I allocate to weapons are "combineable" with each other.
(i.e. basically what item effects are possible; I could give examples if needed)
(Standard dm items are reproducible, but I am interested in dual
wield or 2h weapons usages(at least for now) and some other features of items.
There is a "teleport ability" (found in "sticky topic" mentioned above) that I would assign to a key ,for instance with a timer if possible.
With item creation , there is dungeon mechanics involved as well.
(adding light level to a light emmitting sword, you get the idea).
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

All items are listed in dsb/base/object.lua (you can edit it with notepad /emacs /scite etc. )

These are archetypes, meaning definition of item classes. You can easily add one (I've already done that for test purpose), just copy paste the more identical item you can find :) Then you will be able to spawn instances of it in your dungeon.

At the end of objects.lua there is a set of functions that describe some of the items behaviors. If you have programming bases, it should be easy to understand.

For 2h and dual wield, I assume it is possible to make : a weapon that fills both hands (but I don't quite see the interest of that) or a weapon, worn in left hand, that adds an attack method. But I'm not sure of the details.

For light emitting swords, I suppose torch or illumulet are good items to start with :)

If you want to see how effects can be implemented, you can look for the curse effect (not sure it is in the object.lua file)
What Is Your Quest ?
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Post by zoom »

Thanks Joramund!
I'll take a look at dsb/base/object.lua.
Basically I see what you suggest.

as for programming bases I have nothing except for a bit of turbo pascal and just started on common LISP;that will take a while to fully grasp, but it is interesting.So, I hope I will have a rough idea what sth. does. Probably a bit of csbuild experience also helps.. maybe more than my puny programming ability ;)
I
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

Well you don't need to know many thing to understand LUA, except that :
There are three main types of values :
- numbers (no difference between integers and real)
- strings (between " " or ' ' is almost the same )
- boolean ( true or false )
plus the special value : nil which means to erase the variable.

Then you stuff things within "tables" almost equal to : lists / arrays / vectors etc. They are very flexible :
my_table = { "Hi", 42, "Spam", egg = "chicken" }
will give the four members :
my_table[1] is "Hi"
my_table[2] is 42
my_table[3] is "Spam"
my_table[egg] is "chicken"

And you can see how practical that can be. Tables does not have any limitations (you don't need to specify their size etc.)

As an example, the "obj ={ ... }" at the beginning of object.lua actually define a table called obj containing all object types.

An advanced feature of LUA is the for loop :

for key,value in pairs(obj) do
...
end

Will take all members in the obj table, that is all dsb items, and do whatever you want it to do. I used that to drop lots of stuff in the test dungeon. key and value are just variable names, you can call them whatever you want, it is the pairs() function that returns all members from the table one by one and put them into the pair (key, value) where :
- key would be 1,2,3 or egg in the previous example
- value would be "Hi" etc.

Note that since you can mix numbers and words for keys, the pairs() function does not garantee the order in which elements are returned.
What Is Your Quest ?
User avatar
mikko
Craftsman
Posts: 102
Joined: Sun Jan 15, 2006 2:42 pm
Location: Helsinki, Finland

Post by mikko »

That kinda resembles Python, but sounds simpler.. Any thoughts on this? I haven't done much with LUA, but quite a few things with Python.
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

It is excatly what you just said : Python, but simpler, having a slighlty lighter and clearer syntax and not indent-sensitive.
You can also use variable to "name" functions and call them, and have therefore functions as members of a table.

More advanced features exists, but they are not relevant with DBS editing. You can have a look at lua.org (the user wiki and online books especially)
What Is Your Quest ?
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Post by zoom »

As far as I see it ,lua is also similar to Lisp.

fyi: some info(2nd chapter) of a book I borrowed of a friend
|Paul Graham: ANSI common lisp.
the book says it is available for download but I think they ditched it ..
http://lib.store.yahoo.net/lib/paulgraham/acl2.txt
Post Reply