How do I copy items from the base luas for modification?

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
boyflea
Expert
Posts: 292
Joined: 20-Nov-06 14:23
Location: Southampton, UK
Contact:

How do I copy items from the base luas for modification?

Post by boyflea » 3-Oct-14 22:05

Hi,
just a quickie that's not clear:

base folder has all the cool lua that I've been ransacking to steal ideas from.
in system.lua, there's a cool thing that resumes gave after savegame.
great

Code: Select all

-- This function is called when the game's main loop begins. CUSTOM
function sys_game_beginplay()
	gt_highlight = nil
	gt_spell_flash = nil
	dsb_sound("snd.cat", true)
	return nil
end
and if I edit this in system.lua, then this works, the extra line where I resume a looped audio works.

however, if I copy this same content to my game folder, startup.lua, the dsb_sound does not work, complaining that it is nil.

specifics of this bug aside, what makes processing the system.lua different from processing the startup.lua? are all teh assets in teh correct place?
do I just need to copy elsewhere?

I refer to the code notes:

Code: Select all

-- System functions base config script
-- IT'S NOT A GOOD IDEA TO CHANGE THINGS IN HERE UNLESS
-- YOU KNOW WHAT YOU'RE DOING, but reading this file over
-- is a good way to get to know how DSB works.

-- If you want to override these functions, you should
-- do so in your own dungeon's startup.lua instead.

-- These are all called by the engine at various times
-- to allow for customizability of various events. you
-- NEED these functions or the game won't work!

I am trying to override the function by pasting again into startup.lua - but I sense this is not the thing to do.

DAVE
The stonework walls were pristine, the floor level, the waterworks and drains complete. The lighting network was in and the Dragon in the basement was grumpily heating the water-pipes: Lord Chaos consulted the blueprints again, looking for the bathroom.

User avatar
Sophia
Concise and Honest
Posts: 3909
Joined: 12-Sep-02 19:50
Location: Nowhere in particular
Contact:

Re: How do I copy items from the base luas for modification?

Post by Sophia » 4-Oct-14 00:17

Overriding the function by putting it into your own startup.lua is the correct procedure.

The reason things are going wrong in this case is because dsb_sound needs an actual sound for a parameter, not a string. In other words, you need to just pass snd.cat, not "snd.cat" with the quotes.

Code: Select all

function sys_game_beginplay()
   gt_highlight = nil
   gt_spell_flash = nil
   dsb_sound(snd.cat, true)
   return nil
end
That said, I am not sure if this code is going to do what you probably intend. DSB remembers sounds when you save, so starting a new looping sound every time you reload will lead to an overlaying cacophony fairly quickly.

User avatar
boyflea
Expert
Posts: 292
Joined: 20-Nov-06 14:23
Location: Southampton, UK
Contact:

Re: How do I copy items from the base luas for modification?

Post by boyflea » 4-Oct-14 23:20

cheers for the feedback. I realised as I was posting this that the savegame should capture this, I'll test again to see if it does replay when restarting game, rather than just loading the game up.

Overall, have been spending the past two weeks putting together my test dungeon and apart from the following points its there:
NPC behaviour, special grapple-hook fix, endings and secret counter.

Will QA and post soon: DSB is really cool and the lua-base has real possibilities. RTC does offer some nicer alternatives built-into the editor, but if these can be replicated in DSB then the issue goes away: DSB is harder to get into but ultimately should be more rewarding. :)

will keep you posted and thanks again to all the interest.
DAVE
The stonework walls were pristine, the floor level, the waterworks and drains complete. The lighting network was in and the Dragon in the basement was grumpily heating the water-pipes: Lord Chaos consulted the blueprints again, looking for the bathroom.

Post Reply