Lua Discussion

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
ian_scho
High Lord
Posts: 2806
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Post by ian_scho »

Been looking at some Lua tutorials and it seems an interesting language to learn. It would seem that most of the other DM engines have a graphical interface with a makro/dsa 'thingy' attached to it too for those that wish to get their fingers burnt and really put some special functionality in their custom dungeon. Documentation would be the thing here, I suppose (Paul Stevens is CONSTANTLY referring people to his docs :P).
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

I've tried to get away from that approach (time will tell if this is a good or bad thing) and instead of having a "default" way and then a way to modify that, simply have the engine call Lua directly and let you do whatever you like.

This means some rather "core" features, such as opening/closing doors, stepping on triggers, and handling the display of chests and scrolls are left up to Lua. This could make things interesting... or confusing. :D

I have, of course, provided scripts that do things the basic DM way, but the sky's the limit, really... ;)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

This could make things interesting... or confusing.
It will also give you the opportunity to do
a lot of debugging of other people's attempts
at cleverness.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Oh goody. :roll:

Seriously, though, it shouldn't be so bad, as long as people are good enough to provide rather minimalist code fragments if the engine is going wrong, so we can be sure it's the engine going wrong, and not simply someone being too clever for their own good.

Programmers seem to have that problem sometimes. :lol:
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

This is (at least) six kinds of awesome!
Sophia wrote:This means some rather "core" features, such as opening/closing doors, stepping on triggers, and handling the display of chests and scrolls are left up to Lua. This could make things interesting... or confusing.
My guess is 'interesting'. After all, if one is interested only in the default behavior of a particular feature, one can just leave it alone, right? I've only just started on the Lua tutorials so maybe I have the wrong idea, but it looks like it is going to make it fairly easy for people to implement whatever changes they want in the code. I was also wondering, and maybe it's a moot point with Lua, but is this an open source type of project?
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Also notice if someone wanted to try to port a complex dungeon, they could certainly try with this
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Parallax wrote:After all, if one is interested only in the default behavior of a particular feature, one can just leave it alone, right?
Right. :)
Parallax wrote:I was also wondering, and maybe it's a moot point with Lua, but is this an open source type of project?
It's pretty much a moot point-- just about anything that you'd be interested in hacking around with will be part of the included Lua scripts, and distributed in source form.
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

Sophia wrote:It's pretty much a moot point-- just about anything that you'd be interested in hacking around with will be part of the included Lua scripts, and distributed in source form.
Cool. Having transparent and customizable mechanics means a lot.
Beowuuf wrote:Also notice if someone wanted to try to port a complex dungeon, they could certainly try with this
Hint hint? :wink:
User avatar
Trantor
Duke of Banville
Posts: 2466
Joined: Wed Mar 09, 2005 4:16 am
Location: Berlin, Germany
Contact:

Post by Trantor »

I just realized that I haven't commented on this yet, so I'll do it now. First of all, it's cool to see you working on something new that seems to be customizable in the highest possible way. What I am wondering is how "technical" this will get for someone who doesn't know zilt about programming (IE: me). Will building a dungeon more or less result in direct programming? I just looked briefly over the tutorials linked by ian_scho, and while Lua seems to be quite an easy language to learn, I still wonder how designing will actually work. I suppose you can do practically anything you want to if you program it yourself, but what about dungeons that only use a few more or less complicated features that are possible in CSBWin or RTC?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

It's not exactly programming, but kind of like the early days of RTC hacking, there's no GUI editor (as such) and you'll probably have to poke around in the text files. The text file is technically a Lua program, but I do provide most of the basic DM functionality, so it's not terribly complex. For example, here's how to make a door+button:

Code: Select all

dsb_spawn("doorframe", 0, 9, 3, CENTER)
targ = dsb_spawn("door_portcullis", 0, 9, 3, CENTER)
tmp = dsb_spawn("doorbutton", 0, 9, 3, CENTER)
exvar[tmp] = { target=targ }
What this means is: spawn a doorframe, spawn a portcullis (and store its id number in "targ"), spawn a doorbutton (and store its id number in "tmp"), and then set the target of the doorbutton (stored in tmp) to the door (stored in targ). The whole "exvar" thing simply refers to using an external variable, which is how DSB stores a lot of data not stored directly by the engine... hopefully this idiom will become familiar with use fairly quickly.

And hopefully it's not too awful. :)
Tom Hatfield
Ee Master
Posts: 688
Joined: Mon May 07, 2001 7:00 pm
Location: Indiana, USA
Contact:

Post by Tom Hatfield »

Two editor options:

ConTEXT (free, enables highlighting)

VSLua (not free, requires Visual Studio, full-blown IDE complete with IntelliSense)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

I use a Lua editor called, rather logically, LuaEdit.

It's free, not too fancy, but it's obviously quite optimized for Lua. :)
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

That's cool to see a new clone, and fully editable by the way :o !

I'll look into lua coding language. I learned it is also used by supreme commander so it will be one stone two hits :P

If it's not too soon, and lua is not too messy, I'll be glad to help you. (I'm a C++ user...)

Does this also means that :
1/ There can be a plugin system (using some additional pieces of code to get new things or not --> simple way of having "mutators" for the game) ?
2/ Anyone can specify his own way of coding a dungeon (like, diverse way to write maps for dungeons, to specify some functionalities...) ?
3/ Anyone can mess up with "core" things, like graphical engine, or (less deep but still core) game mechanics like party [more than 4 char / inventory etc.] / movement / spells / fight / monsters AI ?

:arrow: You'll need a whole forum and code sharing capabilities !

I suppose this also means it will be able to compile under linux, which would be a big progress :) at least for me, would-be Ubuntu user.
DSE
Lo Master
Posts: 364
Joined: Sat Mar 20, 2004 12:22 pm
Contact:

Post by DSE »

Sophia/anyone - recommended lua editor to use ? thanks.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Joramund wrote:1/ There can be a plugin system (using some additional pieces of code to get new things or not --> simple way of having "mutators" for the game) ?
I don't see why not, though are you saying they would be added by the player, not the dungeon designer? I'm not sure if this wouldn't make cheating too easy, and kind of defeat some of the uniqueness of each dungeon.
Joramund wrote:2/ Anyone can specify his own way of coding a dungeon (like, diverse way to write maps for dungeons, to specify some functionalities...) ?
Right. Dungeon.lua is not properly a dungeon itself, but rather, a program that when run generates a dungeon. This means it can do all sorts of things.
Joramund wrote:3/ Anyone can mess up with "core" things, like graphical engine, or (less deep but still core) game mechanics like party [more than 4 char / inventory etc.] / movement / spells / fight / monsters AI ?
Some aspects of the graphics engine can be messed with, others are hardcoded. I'll see about adding new functions if people find they want to be more creative, though. 4 party members is pretty solidly hardcoded, I don't see that changing ever. Movement, spells, fighting, and monster responses are all very flexible, though.
Joramund wrote:I suppose this also means it will be able to compile under linux, which would be a big progress :) at least for me, would-be Ubuntu user.
Hmm. The main libraries I'm using are cross-platform. The Windows API functions I'm using aren't, but they may not be that terribly hard to replace. I'll have to see how this one goes.
Tom Hatfield wrote:Crash report!
This one is the one I've been dreading. It happened to me once, in all my testing-- I was hoping it was cosmic rays. I can't reproduce it. I looked the code over and I don't know what might cause it.
DSE wrote:recommended lua editor to use ?
I use something called, rather fittingly, LuaEdit. Notepad will do in a pinch, but things like syntax highlighting spoil us pretty fast, don't they? ;) There were a couple of other editors mentioned earlier in the thread, but I've never tried them.
User avatar
ian_scho
High Lord
Posts: 2806
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Post by ian_scho »

The LuaEdit official Website, designed for the version 5.0 of Lua, where the editor can be downloaded from here.
DSE
Lo Master
Posts: 364
Joined: Sat Mar 20, 2004 12:22 pm
Contact:

Post by DSE »

thanks guys.
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

Sophia wrote: I don't see why not, though are you saying they would be added by the player, not the dungeon designer? I'm not sure if this wouldn't make cheating too easy, and kind of defeat some of the uniqueness of each dungeon.
Yeah, I was thinking about the normal DM dungeon, and things like modify mechanics. This means releasing a "modular" code for the DM dungeon.
Of course you need something cheat-proof for custom dungeons :) like some sort of compiled version.
Some aspects of the graphics engine can be messed with, others are hardcoded. I'll see about adding new functions if people find they want to be more creative, though.
Great... Well for now, I suppose getting a working dungeon is already a time-consuming goal :P
Hmm. The main libraries I'm using are cross-platform. The Windows API functions I'm using aren't, but they may not be that terribly hard to replace. I'll have to see how this one goes.
Didn't thought of those damn' libraries... Well, there're always emulators...
What Is Your Quest ?
Post Reply