-- place_welcome_mat - Logic and behavior for place-entry welcome mat spawn -- (component of welcome_mat) -- Template attachment: place -- Created by: Patrick Ferland -- Created on: 08/01/2008 -- Revision History -- 08/01/2008 P.Ferland - New script -- 08/19/2008 P.Ferland - Refactored to support respawn -- Constants -- no constants -- Script properties Define Properties() end -- Commands -- no commands -- Triggers Trigger user_enter(user_id, user_object) respawn_user(user_object) end Trigger respawn_user_mat(user) respawn_user(user) end -- Local functions function respawn_user(user) if(HasScriptById(user, '14422:42') == 1) then if(user.target_anchor ~= 'spawn' and string.len(user.target_anchor) > 0) then return end end local welcome_mats = {} local obj = nil for _, obj in ipairs(GetObjectsInPlace()) do if (obj.type == 'welcome_mat') then table.insert(welcome_mats, obj) end end if (#welcome_mats > 0) then -- Select a random mat local mat = welcome_mats[math.random(1, #welcome_mats)] MoveObject(user, mat.x, mat.y, mat.z, 1) PlaySoundPlace(mat.welcome_mat_sound_id, 1, 0) end end