Re: [ASSET] (Released) Particles and alternative teleporters
Posted: Fri Jan 25, 2013 10:47 am
what is the name of your script? the "self" refers to the script id's first 20 characters
Official Legend of Grimrock Forums
http://mail.grimrock.net/forum/
Hi, Komag, love your tutorials first of all.Komag wrote:what is the name of your script? the "self" refers to the script id's first 20 characters
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.
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 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
endCode: 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
endFirst off if I understand correctly your trying to call a method from within the function, IE: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