Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 2994
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Mon Jul 31, 2017 10:13 am

In this case, I want to either mute the level_up sound—just once, or work out a better method that doesn't play the sound when a script improves the PC's skills.

It's not the only time this has come up... There are several internal sounds and other settings that I'd like to change on occasion, but I just don't know how to access them.

User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas » Thu Aug 03, 2017 11:42 pm

Hey guys,
i´m working on a room with burnt out torches the Player has to light up first.
Here is the Code i am using to light a torch up. Works just fine on inserting a torch to the torch holder.

Code: Select all

function torcheffekt()
torch1.particle:enable()
torch1.sound:enable()
torch1.light:enable()
end
I was wondering if i could make this more general, since i have a few more torches and i don´t really want every torch to hook up to an extra script.
Something like this.......only a Version of it that works. This may be pretty Basic stuff but i couldn´t find it anywhere else.

function torcheffekt(torch_holder)
torch_holder.particle:enable()
torch_holder.sound:enable()
torch_holder.light:enable()
end
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!

User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas » Fri Aug 04, 2017 12:11 am

Also why is this not working?

Code: Select all

spawn("mummy2",partylevel,4,22,0,partylevel).monster.onDie(hudPrint("Test"))
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!

User avatar
THOM
Posts: 1175
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Fri Aug 04, 2017 12:19 am

It is not "partylevel" but "party.level"
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

User avatar
Isaac
Posts: 2994
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Fri Aug 04, 2017 2:29 am

Xardas wrote:Also why is this not working?

Code: Select all

spawn("mummy2",partylevel,4,22,0,partylevel).monster.onDie(hudPrint("Test"))
It's more than just party.level. The onDie() function isn't called like that, and when it is called, it is given (automatically) the monster's table for use in the hook, and it has an optional return value that matters. (returning false cancels the death)

Try this:

Code: Select all

spawn("mummy2",party.level,4,22,0).monster:addConnector("onDie", self.go.id, "onDeathAction")

function onDeathAction(self)
	hudPrint(tostring(self.go.name.." #"..self.go.id.." just died on level "..self.go.level.." at location "..self.go.x..","..self.go.y))
end

--		tostring() ensures it's a string, hudPrint() chokes on anything else

User avatar
akroma222
Posts: 1025
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 » Fri Aug 04, 2017 5:45 am

Xardas wrote: I was wondering if i could make this more general, since i have a few more torches and i don´t really want every torch to hook up to an extra script.
Something like this.......only a Version of it that works. This may be pretty Basic stuff but i couldn´t find it anywhere else.

function torcheffekt(torch_holder)
torch_holder.particle:enable()
torch_holder.sound:enable()
torch_holder.light:enable()
end
Hey Zardas!
Try this function (place in a scriptEntity called 'toggleAtorchScript')
the function args tParticle, tSound, tLight require a boolean each
>> true will enable the component, false will disable it
SpoilerShow

Code: Select all

function toggleAtorch(tHolderID, tParticle, tSound, tLight)
	
	if not tHolderID then
		return
	end
	
	local componentTab = {}
	
	componentTab = {particle = tParticle, sound = tSound, light = tLight}
	
	for comp, action in pairs(componentTab) do
		
		--print(comp, action)
		
		local thing = findEntity(tHolderID):getComponent(comp)
		
		if action == true then
			thing:enable()
		else
			thing:disable()
		end
		
	end
end
Eg - To only keep the light component enabled, call it like this:

Code: Select all

toggleAtorchScript.script.toggleAtorch("torch_holder_1", false, false, true)
EDIT: that function can be cut down and simplified a lot actually, will look at it later

User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas » Fri Aug 04, 2017 2:35 pm

Thanks for the answers guys. I made a few spawn commands with partylevel instead of party.level and they seem to be working just fine as well. :) ....
Anyways if you say it´s wrong that way it´s probably better for me to change it.
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!

User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas » Fri Aug 04, 2017 2:40 pm

Oh there is one more Thing....
Where can i read more about the function Parameters and their names?
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!


User avatar
Xardas
Posts: 83
Joined: Fri Jul 28, 2017 12:30 am

Re: Ask a simple question, get a simple answer

Post by Xardas » Sat Aug 05, 2017 8:55 pm

Hey guys,
How does the disableSelf() on Buttons work?
I have a button (disableSelf(true)) hooked up to a script, which spawns mummies. Tought it would make the button trigger only once, but it doesn´t seem to be working this way.

After that i tried it this way:

Code: Select all

function RemoveTombbuttonConnector
     for i = 1, tombbutton.button:getConnectorCount() do                   
     tombbutton.button:removeConnector(tombbutton.button:getConnector(i))
    end
end
end
This should remove the Buttons Connectors. I can´t find the mistake in this one. :( Can anyone help me?
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!

Post Reply