Explanation of DSB base code and game loop, etc?
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting. You may
to help finance the hosting costs of this forum.
Please read the Forum rules and policies before posting. You may

- Gambit37
- Should eat more pies
- Posts: 13773
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Explanation of DSB base code and game loop, etc?
I'm trying to get my head around the base code and game loop, but failing.
Sophia, is it possible for you to write an outline of how all this stuff is processed, and in what order? And also provide info on how this can be overriden by code in a dungeon folder -- and also the setup for those? For example, what .lua files call what other .lua files and in what order?
How do I override a base function? Do I just copy it, change it, and stick it in a lua file in my dungeon folder and that function will be used in preference to the base one? Or is there some sort of cloning that needs to be done?
The big problem I'm finding is that I don't have a good "bigger picture" visual of how all this stuff fits together, and thus how best to manipulate it.
Sophia, is it possible for you to write an outline of how all this stuff is processed, and in what order? And also provide info on how this can be overriden by code in a dungeon folder -- and also the setup for those? For example, what .lua files call what other .lua files and in what order?
How do I override a base function? Do I just copy it, change it, and stick it in a lua file in my dungeon folder and that function will be used in preference to the base one? Or is there some sort of cloning that needs to be done?
The big problem I'm finding is that I don't have a good "bigger picture" visual of how all this stuff fits together, and thus how best to manipulate it.
-
- Adept
- Posts: 221
- Joined: Sat Jan 07, 2006 1:54 am
- Location: Britain
Re: Explanation of DSB base code and game loop, etc?
Lemme try and help...
In your dungeon folder, create startup.lua. Write this:
Everything in example.lua will be loaded, then everything in example2.lua, etc. The files in example.lua can overwrite the base code for that particular dungeon, so you can replace a function in the basecode called sys_example_function with a local variant, also called sys_example_function, if it appears in example.lua.
In your dungeon folder, create startup.lua. Write this:
Code: Select all
lua_manifest = {
"example.lua",
"example2.lua"
}
- Gambit37
- Should eat more pies
- Posts: 13773
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Explanation of DSB base code and game loop, etc?
Great, thanks, that's useful.
What about the processing order of the base files? Would be useful to know this so I can start to understand the flow a bit better. Sophia?
What about the processing order of the base files? Would be useful to know this so I can start to understand the flow a bit better. Sophia?
- Sophia
- Concise and Honest
- Posts: 4307
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Explanation of DSB base code and game loop, etc?
Well, the processing order of the files doesn't really give you that much insight into the program flow, but, to answer your question: First, DSB loads base/global.lua. It then handles the lua_manifest as given there. It then loads base/startup.lua. Lastly, it loads the startup.lua as specified in your dungeon, and handles its lua_manifest.Gambit37 wrote:What about the processing order of the base files? Would be useful to know this so I can start to understand the flow a bit better. Sophia?
To get a feel for the program flow, it might be better to think about what kinds of things you'd like to change. Usually, objects have various on_* functions, message handlers, attack methods, and such things, that govern what they do under certain conditions. You can then delve into the code and see what the function's parameters are and what it does. Sometimes it's not clear what file the function you want is in-- LuaEdit can be very valuable here because you can just open a bunch of base code files and search them all quickly. Other interesting files to look at would be system.lua and hooks.lua. They are almost the same thing, only system.lua contains functions invoked by the core engine (the C part) where hooks.lua contains various things done by the base code (the Lua part) that you might want to hook. This actually makes me think of another problem, but I'll post about that in another thread.
-
- Adept
- Posts: 221
- Joined: Sat Jan 07, 2006 1:54 am
- Location: Britain
Re: Explanation of DSB base code and game loop, etc?
I actually uninstalled and removed LuaEdit the third time it accidentally dropped my whole dungeon in the recycle bin, and I'm currently editing in notepad again.
Re: Explanation of DSB base code and game loop, etc?
Mon Ful Ir: try "Scite", it's a cool open source text editor, much more powerful than the notepad.
What Is Your Quest ?
Re: Explanation of DSB base code and game loop, etc?
You may also think about using the free available MSVC-express-version.
It's not necessary to program something, you can setup a project with several files, and then use a powerful find/replace-in-project function.
It's not necessary to program something, you can setup a project with several files, and then use a powerful find/replace-in-project function.
- linflas
- My other avatar is gay
- Posts: 2445
- Joined: Tue Nov 04, 2003 9:58 pm
- Location: Lille, France
- Contact:
Re: Explanation of DSB base code and game loop, etc?
why using such complicated tools ?
notepad plus plus : free, smart, easy.
notepad plus plus : free, smart, easy.
"The only way out is another way in." Try Sukumvit's Labyrinth II
- Gambit37
- Should eat more pies
- Posts: 13773
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Explanation of DSB base code and game loop, etc?
I tried Notepad++ for HTML/CSS work and simply didn't like it. Plus I'm not sure it does code colouring for Lua does it?
- linflas
- My other avatar is gay
- Posts: 2445
- Joined: Tue Nov 04, 2003 9:58 pm
- Location: Lille, France
- Contact:
Re: Explanation of DSB base code and game loop, etc?
i use it everyday for html/css/php/perl/lua etc. ! i especially like the incremental search (i re-mapped it to CTRL-F), the string search on several files, and the way you can edit any language syntax highlighting by simple clicks.
"The only way out is another way in." Try Sukumvit's Labyrinth II
Re: Explanation of DSB base code and game loop, etc?
Didn't know that one. Got extremely good ratings. Must try - thx!
Now back to topic
(perhaps shift the last posts to the 'interesting tools'-thread I once made)
Now back to topic

(perhaps shift the last posts to the 'interesting tools'-thread I once made)