Page 1 of 1

Spawning a Pressure Plate Help?

Posted: Sat Oct 19, 2013 1:34 am
by fazzasx
Hi Everyone :)

I have used the following code to spawn a pressure plate, however when I do this I notice that once its spawned the surrounding area or (border) around the pressure plate starts moving or flickering?

Has anyone else experienced this or know what it might be please? I have tried altering my graphics settings but that does not resolve it. It only happens if I spawn a new pressureplate... Whats also odd is that after a period of time it just stops flickering.

Let me know if anyone has a fix or possible workaround.

-- Pressure Plate Generation Section

function presp1()
spawn("deep_temple_pressure_plate", party.level,10,18,1,"prespt2")
playSoundAt("wall_sliding_lock",party.level,10,18)
party:shakeCamera(0.2,0.2)
prespt2:addConnector("activate", "script_entity_28", "presp2")
prespt2:setActivateOnce(true)

Many Thanks

Re: Spawning a Pressure Plate Help?

Posted: Sat Oct 19, 2013 1:56 am
by DesperateGames
Hello fazzasx,

I have experienced similar problems whenever the model that is spawned overlaps with an already existing entity. For example, I experience this when I put two floor_dirt decorations in the same tile. Or when I start spawning pillars over already existing pillars. This seems to be a custom made pressure plate..could it be that it has a different model and that it overlaps a bit with the surrounding floor tiles? Can you maybe post a screenshot where you can mark the flickering parts?

Re: Spawning a Pressure Plate Help?

Posted: Sat Oct 19, 2013 2:04 am
by Dr.Disaster
The reason why it flickers is as DesperateGames already said. Your spawned pressure plate overlaps with the previously present floor tile. It's fairly easy to reproduce with any kind of tileset; just use your spawn command inside the editor.

The only way to remove such flicker is to remove any previously present floor element so the pressure plate is the only floor element on the tile it spawned on. The editor does exactly this. Now if you're going to ask me how to destroy a default floor tile outside of the editor .. sorry i don't know.

Re: Spawning a Pressure Plate Help?

Posted: Sat Oct 19, 2013 2:14 am
by fazzasx
Thanks for the reply guys, I just figured out that it is to do with the tileset so I need to clone a pressure plate border and remove the pressure plate and make that into a prop I guess.

This is really usefull thanks for the information :)

Re: Spawning a Pressure Plate Help?

Posted: Sat Oct 19, 2013 6:31 am
by Diarmuid
Unfortunately you cannot remove static dungeon elements (floors, walls, etc.) once they are created when the dungeon first loads.

You can however prevent the engine from putting a "default" floor, by putting yourself a decoration with replacesFloor = true. Then you have a decoration entity that you can interact with. In objects.lua for example, clone a decoration that has it, like dungeon_floor_drainage, and change the model to be the "normal" floor you want to use. Then, when you want to spawn your pressure plate, destroy the decoration and spawn the plate. Destroy the plate and spawn the floor when you want it back.

For reference, here is a dungeon_floor decoration, which when you put it in the editor, doesn't seem to do anything. It just replaces the static floor with a decoration one. But then you can destroy it if you want.

Code: Select all

defineObject{
	name = "dungeon_floor_decoration",
	class = "Decoration",
	model = "assets/models/env/dungeon_floor_01.fbx",
	placement = "floor",
	replacesFloor = true,
	editorIcon = 136,
}

Re: Spawning a Pressure Plate Help?

Posted: Sun Oct 20, 2013 12:42 am
by fazzasx
Diarmuid wrote:Unfortunately you cannot remove static dungeon elements (floors, walls, etc.) once they are created when the dungeon first loads.

You can however prevent the engine from putting a "default" floor, by putting yourself a decoration with replacesFloor = true. Then you have a decoration entity that you can interact with. In objects.lua for example, clone a decoration that has it, like dungeon_floor_drainage, and change the model to be the "normal" floor you want to use. Then, when you want to spawn your pressure plate, destroy the decoration and spawn the plate. Destroy the plate and spawn the floor when you want it back.

For reference, here is a dungeon_floor decoration, which when you put it in the editor, doesn't seem to do anything. It just replaces the static floor with a decoration one. But then you can destroy it if you want.

Code: Select all

defineObject{
	name = "dungeon_floor_decoration",
	class = "Decoration",
	model = "assets/models/env/dungeon_floor_01.fbx",
	placement = "floor",
	replacesFloor = true,
	editorIcon = 136,
}
Hi Diarmuid, what you suggested indeed worked :) thankyou so much. I was really worried that I would not be able to figure it out but its working now and for anyone else wanting something similar here it is

Code: Select all

-- Pressure Plate Generation Section

function presp1()
	dtfd1:destroy() -- Destroy Decorative Floor
		spawn("deep_temple_pressure_plate", party.level,10,18,1,"prespt2") -- Create pressure plate in desired location
			playSoundAt("wall_sliding_lock",party.level,10,18) -- add some cool sound to it
				party:shakeCamera(0.2,0.2) -- shake the camera baby ;)
					prespt2:addConnector("activate", "script_entity_28", "presp2") -- connect the pressure plate to the required script entity and function
					prespt2:setActivateOnce(true) -- set to activate only once, this is your call I guess 
end