Page 83 of 400

Re: Ask a simple question, get a simple answer

Posted: Mon Aug 17, 2015 10:05 pm
by Drakkan
aaneton wrote:How do I check if a alcove has an item with a specific trait, e.g. I want to check if an alcove surface has a two-handed sword placed on surface. The traits would be "two_handed" and "sword".
I believe you can use modified script which was used for glutony shrine in original dungeon (just changing trait you need / number of required objects and what need to be triggered eventualy)

Code: Select all

function checkItems(surf)
	local count = 0
	
	for _,i in surf:contents() do 
		if i:hasTrait("consumable") then
			count = count + 1
		end
	end
	
	if count >= 3 then
		gluttonDoor.door:open()
	else
		gluttonDoor.door:close()
	end
end

Re: Ask a simple question, get a simple answer

Posted: Mon Aug 17, 2015 10:17 pm
by aaneton
Drakkan wrote:
aaneton wrote:How do I check if a alcove has an item with a specific trait, e.g. I want to check if an alcove surface has a two-handed sword placed on surface. The traits would be "two_handed" and "sword".
I believe you can use modified script which was used for glutony shrine in original dungeon (just changing trait you need / number of required objects and what need to be triggered eventualy)
Excellent. Thanks!

Re: Ask a simple question, get a simple answer

Posted: Tue Aug 18, 2015 10:21 pm
by Kuro01
Anyone have imfo somewhere on how to spawn a pressure plate or a lever and then set the components and connectors?

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 12:54 pm
by Nero44
Can a floor trigger only be activated when the party is facing in a certain direction ?

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 1:19 pm
by Isaac
Nero44 wrote:Can a floor trigger only be activated when the party is facing in a certain direction ?
Here are two methods.

For the the first you define this particular floor_trigger as a custom object.

Code: Select all

defineObject{
	name = "floor_trigger_checked",
	baseObject = "floor_trigger",
	components = {
		{
			class = "FloorTrigger",
			onActivate = function(self) if party.facing ~= self.go.facing then return false end end,
		},
	},
}

Alternatively, you can connect the floor_trigger to a script_entity, and call the connection manually:

Code: Select all

function faceCheck(self) 
	if party.facing == self.go.facing then
		my_door.door:open()
 	end
end
*In both cases, it's setup that the facing of the floor_trigger, is the facing it checks for, before activating.

The floor_trigger should be set to only trigger for the party, unless you add a condition that checks that the party is standing on the floor_trigger; (that both are in the same tile). Also these do not account for the party turning in place; that requires a party onTurn hook... which can be done easy enough, but that changes the core behavior of the floor_trigger (as does having the facing check to begin with).
______________




Kuro01 wrote:Anyone have imfo somewhere on how to spawn a pressure plate or a lever and then set the components and connectors?
You use the Spawn function, and then call the spawned object's addConnector function, and give it the parameters to indicate how and what to connect to.

Example:

Code: Select all

spawn("dungeon_pressure_plate",1, 15,15,0,0).floortrigger
	:addConnector("onActivate", spawn("dungeon_door_iron",1,15,15,0,0).id, "open") 
A more clear example: ;)

Code: Select all

spawn("dungeon_pressure_plate",1, 15,15,0,0, "my_plate")
spawn("dungeon_door_iron",1,15,15,0,0, "my_door")
my_plate.floortrigger:addConnector("onActivate", "my_door", "open") 
*They both do the same thing.

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 11:01 pm
by THOM
I am trying to check, if a certain monster is still alive on the map (and I can do something with it).

Code: Select all

if ratling1_1.monster:isAlive() then
doesn't seem to work, because if this monster is dead (and not on the map) I got an error message ("nil value")

so what to do?

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 11:20 pm
by minmay
check that ratling1_1 exists first...

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 11:22 pm
by THOM
I thought, I do that... :?

So isAlive doesn't check, if a monster exists - but what than? How can a monster exist but being not alive???

Re: Ask a simple question, get a simple answer

Posted: Sun Aug 23, 2015 11:44 pm
by AndakRainor

Code: Select all

if ratling1_1 ~= nil and ratling1_1.monster:isAlive() then ... end
When a monster dies, it still exists for a few seconds (before some kind of garbage collector eats it ?!).

Re: Ask a simple question, get a simple answer

Posted: Mon Aug 24, 2015 12:12 am
by minmay
THOM wrote:I thought, I do that... :?

So isAlive doesn't check, if a monster exists - but what than? How can a monster exist but being not alive???
you're trying to call a function named "isAlive" belonging to a table named "monster" belonging to a table named "ratling1_1" in the global environment. if ratling1_1 is nil, i.e. doesn't exist, you can't index it, so you get an error when you try