Page 206 of 376

Re: Ask a simple question, get a simple answer

Posted: Mon Jul 31, 2017 10:13 am
by Isaac
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.

Re: Ask a simple question, get a simple answer

Posted: Thu Aug 03, 2017 11:42 pm
by Xardas
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

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 12:11 am
by Xardas
Also why is this not working?

Code: Select all

spawn("mummy2",partylevel,4,22,0,partylevel).monster.onDie(hudPrint("Test"))

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 12:19 am
by THOM
It is not "partylevel" but "party.level"

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 2:29 am
by Isaac
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

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 5:45 am
by akroma222
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

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 2:35 pm
by Xardas
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.

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 2:40 pm
by Xardas
Oh there is one more Thing....
Where can i read more about the function Parameters and their names?

Re: Ask a simple question, get a simple answer

Posted: Fri Aug 04, 2017 3:25 pm
by zimberzimber

Re: Ask a simple question, get a simple answer

Posted: Sat Aug 05, 2017 8:55 pm
by Xardas
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?