[ASSET] (Released) Particles and alternative teleporters

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [ASSET] (Released) Particles and alternative teleporters

Post by Komag »

what is the name of your script? the "self" refers to the script id's first 20 characters
Finished Dungeons - complete mods to play
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: [ASSET] (Released) Particles and alternative teleporters

Post by Grimfan »

Komag wrote:what is the name of your script? the "self" refers to the script id's first 20 characters
Hi, Komag, love your tutorials first of all. :D

Funny thing is that LordYig told me (in the Readme) to quote:
Create a new script entity in your dungeon and name it as you like.
A strong reference to the teleporter function is advised in the name
of the entity in order to easily keep track of what has been done.

Following that I've called it everything from teleporterpurple to purpleFlashPort, to leaving it as script_entity_2 without success). As for the script itself it's part of a larger script that looks like this (and I'm assuming is meant to allow for multiple different colored teleporters to run off of the one script so you're not cluttering up the dungeon).

Code: Select all

-- Play the right ScreenEffect for the teleporter
	function FlashRed(self)
		local teleporter_id = self.id:sub(1,17)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_red_screen_01")
		end
	end
	function FlashBlue(self)
		local teleporter_id = self.id:sub(1,18)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_blue_screen_01")
		end
	end
	function FlashGreen(self)
		local teleporter_id = self.id:sub(1,19)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_green_screen_01")
		end
	end
	function FlashYellow(self)
		local teleporter_id = self.id:sub(1,20)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_yellow_screen_01")
		end
	end
	function FlashPurple(self)
		local teleporter_id = self.id:sub(1,20)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_purple_screen_01")
		end
	end
	function FlashCyan(self)
		local teleporter_id = self.id:sub(1,18)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_cyan_screen_01")
		end
	end
	function FlashWhite(self)
		local teleporter_id = self.id:sub(1,19)
		local teleporter_entity = findEntity(teleporter_id)
		if teleporter_entity:isActivated() then
			party:playScreenEffect("teleport_white_screen_01")
		end
	end 
User avatar
LordYig
Posts: 175
Joined: Wed Jul 04, 2012 5:45 pm

Re: [ASSET] (Released) Particles and alternative teleporters

Post by LordYig »

Hello,

First, thanks for using this resource GrimFan.

The scripting part from this resource, for handling screen effects, was a quick solution I came up with and is far from perfect.
I think you have encountered one of its limit.
For this to work you must strictly follow the pattern from the resource and this is quite restrictive I guess.
Actually, the problem you are encountering came from the object name (the teleporter name).
And, the self from the script refer to the base object name calling the script.

Here are comments added to the code taken from the readme :

Code: Select all

-- Call FlashPurple from an entity refered as self
-- The entity is the pressure plate calling the function
function FlashPurple(self)
	-- Find the teleporter id
	-- Purple teleporter base object from teleporters.lua is named "teleporter_purple_01"
	-- In my testing dungeon teleporters are named "teleporter_purple_01", "teleporter_purple_02", etc.
	-- pressure plates are named "teleporter_purple_01_flash", "teleporter_purple_02_flash", etc.
	-- We take the first 20 characters of the pressure plate name to find the associated teleporter name
	-- The name must be unique to be sure we have the correct entity placed at the same location than the pressure plate
	local teleporter_id = self.id:sub(1,20)
	-- Find the teleporter entity
	local teleporter_entity = findEntity(teleporter_id)
	-- If the associated teleporter is activated play the effect
	if teleporter_entity:isActivated() then
		party:playScreenEffect("teleport_purple_screen_01")
	end
end
The fact that you renamed the teleporter entity "myteleporter_purple_1" and "myteleporter_purple_2" is causing this problem I guess.

This is not really clear from my explanation in the readme I guess but the teleporter object and the associated pressure plate must share the same base name for this to work properly.

So image you have 4 purple teleporters. Those should be named : teleporter_purple_01, teleporter_purple_02, teleporter_purple_03, teleporter_purple_04.
And the associated pressure plates could be named : teleporter_purple_01_flash, teleporter_purple_02_flash, teleporter_purple_03_flash, teleporter_purple_04_flash
The important point is that each teleporter must share the same portion of name with its associated pressure plate for the script to check the correct entity.

In your case you add do it an alternative way:
4 purple teleporters: myteleporter_purple_1,myteleporter_purple_2, myteleporter_purple_3, myteleporter_purple_4
4 pressure plates : myteleporter_purple_1_flash,myteleporter_purple_2_flash, myteleporter_purple_3_flash, myteleporter_purple_4_flash

But you must change the code a bit for this to work :

Code: Select all

-- Call FlashPurple from an entity refered as self
-- The entity is the pressure plate calling the function
function FlashPurple(self)
	-- Find the teleporter id
	-- The custom entity names (unique part) are myteleporter_purple_1, myteleporter_purple_2, that's 21 characters long
	-- We take the first 21 characters of the pressure plate name to find the associated teleporter name
	-- The name must be unique to be sure we have the correct entity placed at the same location than the pressure plate
	local teleporter_id = self.id:sub(1,21)
	-- Find the teleporter entity
	local teleporter_entity = findEntity(teleporter_id)
	-- If the associated teleporter is activated play the effect
	if teleporter_entity:isActivated() then
		party:playScreenEffect("teleport_purple_screen_01")
	end
end
This is not tested, I hope I did not make any mistake in this code :?
If this did not work, please report it back, I'll try to help you with this.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: [ASSET] (Released) Particles and alternative teleporters

Post by Grimfan »

Thanks LordYig. That was the problem. the function was reading the _flash part and having issues. Once I peeled it back it worked great. :D

And thanks again for the great resources you have provided. Both this and the adventurers food supply really have given people a lot of variety to work with. Expect a big thanks from me if I ever bring out a dungeon. :)
User avatar
LordYig
Posts: 175
Joined: Wed Jul 04, 2012 5:45 pm

Re: [ASSET] (Released) Particles and alternative teleporters

Post by LordYig »

Glad to read that the problem is solved.

Be persistent in your work and your dungeon.
The hardest part in any modding project is having the resilience when facing problems and keeping your own pace until achieving a satisfying result.
I find it hard sometimes, but after a short break I can go back to the editor and other tools I'm using to finish my current asset or start something new.

I'll gladly play your dungeon when you'll release it, even in a few month from now. ;)
Versalogic
Posts: 2
Joined: Wed Jan 29, 2014 4:12 am

Re: [ASSET] (Released) Particles and alternative teleporters

Post by Versalogic »

function FlashPurple(self)
local teleporter_id = self.id:sub(1,20)
local teleporter_entity = findEntity(teleporter_id)
if teleporter_entity:isActivated() then - attempt to index local 'teleporter-entity' (a nil value) x
party:playScreenEffect("teleport_purple_screen_01")
end
end
First off if I understand correctly your trying to call a method from within the function, IE:
teleporter_entity if I am understanding is your script entity

If this is the case, this will not work if teleporter_entity:isActivated() then

teleporter_entity holds your scripts functions and processes those functions depending if a result is a boolean expression

in otherwords your using plates to control a function, so your function needs to know the result being passed to the script in
order to test your functions result.

so assuming this teleporter_entity is connection rather then your test in this equation.....

You need to have the script determine what the result within your defined function is evaluated too.

Primarly what im saying is more like you need to test the condition of the target etc if boolPlate:isDown() then
where boolPlate is a pressure_plate obviously..


hope this helps :)
Versalogic
Posts: 2
Joined: Wed Jan 29, 2014 4:12 am

Re: [ASSET] (Released) Particles and alternative teleporters

Post by Versalogic »

Ok for whatever reason this page did not fully load, at the time of this post
and now all of a sudden there are 4 replies to the author and his issue.
do please do ignore this reply and the one before it. since now I look
like a moron for responding a day late and a $1 short lol.
Post Reply