[Models] New created Models..

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Models] New created Models..

Post by Isaac »

chaoscommencer wrote:Sorry I didn't catch that; I just sort of assumed he was using an alcove for the patch area as well. Actually is there a way to instantiate two items as one? In this case for example he needs a lever and an alcove for this patchable gas flow controller. Can you define an object type that inherits both lever and alcove? Or do you need to manually place both objects? I've seen this problem pop up in other places too like with Skuggasveinn's town door. Anything really that you need to place two or more objects to get all the desired functionality.
Well... As far as I know, you have to stick to the classes; you have to define each object as the class of choice. But what you can do for for a complex set of objects that all have to show up in the same cell with the same facing, is write a script for it.

For example: Say you want a button, and two decorations to be placed as a set. You can place a script object that spawns all of those items in relation to each other.
Like this...

Code: Select all

-- In the script Object; named 'MyScriptedSet'
spawn('wall_button', MyScriptedSet.level, MyScriptedSet.x, MyScriptedSet.y, MyScriptedSet.facing)
spawn('dungeon_ivy_2', MyScriptedSet.level,MyScriptedSet.x, MyScriptedSet.y, MyScriptedSet.facing)
spawn('gobelin', MyScriptedSet.level, MyScriptedSet.x, MyScriptedSet.y, MyScriptedSet.facing)
Those items will appear anywhere you place a copy of that script, and the items match the facing. This works well if you are not replacing any wall.

A variation of this is to rewrite the script to be called by other scripts, and use their location and facing; this cuts down on duplicate code; because you don't need copies of the spawned-set script everywhere, just ones that call it.

Code: Select all

-- Script object named 'myTemplate'
function createSet(caller)
spawn('wall_button', caller.level, caller.x, caller.y, caller.facing)
spawn('dungeon_ivy_2', caller.level,caller.x, caller.y, caller.facing)
spawn('gobelin', caller.level, caller.x, caller.y, caller.facing)
end
And then you place scripts that call the myTemplate.createSet() function.

Code: Select all

myTemplate.createSet(self)
When I was doing this it was with a set of ten objects that all had to be spawned and facing the same direction; this worked perfectly for that... But it's a bit much for two or three items, and it won't replace walls, so the steam valve in this case would have to be on the map at load; (unless it was worth it to open the cell on the map, and spawn objects with collision to plug up the hole).

Here is a more practical use for it:
Put this in a script by a wall, facing away from it.

Code: Select all

if not extinguished_torch then
	spawn('torch_holder', self.level, self.x, self.y, self.facing, 'extinguished_torch')
	extinguished_torch:addItem(spawn('torch'))
	extinguished_torch:destroy()
	spawn('torch_holder', self.level, self.x, self.y, self.facing, 'extinguished_torch')
end
A shorter, but more cryptic version would be:

Code: Select all

	spawn('torch_holder', self.level, self.x, self.y, self.facing):addItem(spawn('torch')):destroy()
	spawn('torch_holder', self.level, self.x, self.y, self.facing)
*This one you can just place any number of them anywhere on the map, with no modifications.
Last edited by Isaac on Tue Feb 04, 2014 10:31 am, edited 2 times in total.
User avatar
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: [Models] New created Models..

Post by germanny »

Nice help, thanks!
At first i wanted to set an invisible button on the leak. On push, If active party member has both patch+tools in hand,
a (already finished) 'wall decoration' patch spawns at this point and return tubeFixed = true for further use.
Also remove patch item from member.

But with alcove (i didn´t thought of that lately) it seems a bit easier to script. Will check that out!
What is left? The loop sound thing. There´s no easy workaround..mmh ..

Tought of let a button play the loop sound, but it is a dumb idea, bcause the button´s script did playSoundAt(loop)
so the sound stays where it is.. :/
I have to use an object that plays sound by itself - a DOOR^^ May work with a loop sound? And if destroyed.. will check.
Dungeon Master Resource Pack worker and passionated Beer drinker
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: [Models] New created Models..

Post by maneus »

Why not define the loop sound new without a loop?

loop = false,
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [Models] New created Models..

Post by Komag »

If you have a relatively short sound with a fade in and fade out, you can have a timer repeatedly play that single non-looping sound, then when it gets fixed, just don't repeat it anymore and it will fade out after a few more seconds
Finished Dungeons - complete mods to play
User avatar
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: [Models] New created Models..

Post by germanny »

maneus wrote:Why not define the loop sound new without a loop?
Because i need a steam noise, and as long as the leak is open - it should play^^
Komag wrote:If you have a relatively short sound with a fade in and fade out, you can have a timer repeatedly play that single non-looping sound, then when it gets fixed, just don't repeat it anymore and it will fade out after a few more seconds
This is an idea i had in mind, too. Well, many things to check and do for my idea with fixing a leak^^

Maybe i just release the dm-wallset update and see what others can do; i have to expand the manual, finish asset listings
and i wanted to do a bit better example dungeon with all new assets showing.

I can and will not create a whole functional dungeon yet - it´s only an asset pack^^
Building a new custom dungeon was my plan, i gathered some ideas and a story. But with LoG 2 then!
Dungeon Master Resource Pack worker and passionated Beer drinker
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Models] New created Models..

Post by Isaac »

Komag wrote:If you have a relatively short sound with a fade in and fade out, you can have a timer repeatedly play that single non-looping sound, then when it gets fixed, just don't repeat it anymore and it will fade out after a few more seconds
This would work well with sputtering steam.
________________

This seems to work:
First: define a new sound, in sound.lua.

Code: Select all

defineSound{
		name = "my_custom_loop",
		filename = "assets/samples/env/teleporter_ambient_01.wav",
		loop = false,
		volume = 0.7,
		minDistance = 1,
		maxDistance = 6,
	}
Next add a button or Alcove and a timer in the same cell; add a script.
(Alcoves set to 'always activate')

Add this to the script:

Code: Select all

function loopedSound(self)
	playSoundAt('my_custom_loop',self.level, self.x, self.y)
end
Set the timer to 2.95 (you'll have to tweak it to match any other sound).

Connect the timer to the script. Connect the button or alcove to the timer and to the script (set it to Toggle the timer).
______________________________________

The button (or alcove) will start the sound, and stop the sound. If you want the sound to start when the level loads, set the timer to 'activated'.
chaoscommencer
Posts: 119
Joined: Sun Jan 05, 2014 7:48 pm

Re: [Models] New created Models..

Post by chaoscommencer »

Nice tip on the spawner script object. That could definitely come in handy.
Working on a dungeon that displays a massive collection of assets while sorting them into convenient reusable plugin format (concept from some of leki's mods). Will contribute some of my own models as well eventually and follow that with custom dungeon.
User avatar
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: [Models] New created Models..

Post by germanny »

Thanks isaac, the sound effect plays if i open the steam valve and stops after closed!

Now i have to de/activate the timer from script in that way: if the tube is fixed the fx and sound won´t spawn anymore.
Cool!
Dungeon Master Resource Pack worker and passionated Beer drinker
User avatar
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: [Models] New created Models..

Post by germanny »

Yeah, i got the tube fixing scripts to work!
Too bad written to show up here xD - i have to rewrite the code a bit..

Thanks to all who helped me there, this was no easy task. the whole story teached me to understand
many things much better and will definitely help me in other cases!

Will describe it in detail later here, now it´s bedtime^^
Dungeon Master Resource Pack worker and passionated Beer drinker
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Models] New created Models..

Post by Isaac »

Good to hear it; I'm looking forward to seeing it in action.
Post Reply