-- makefile - Avatars installation file -- (plugin for avatars_lite) -- Template attachment: none -- Created by: Patrick Ferland -- Created on: 10/16/2008 -- Revision History -- 10/16/2008 P.Ferland - New script -- Constants PLAYER_AVATAR_SCRIPT = '8282:16' PLAYER_AVATAR_MOVE_SCRIPT = '8282:17' PLAYER_AVATAR_CUSTOMIZATION_SCRIPT = '8282:52' PLAYER_TEMPLATE = '0:1' -- Script Properties -- no properties -- Triggers Trigger module_import(module_world_id, module_name, user) Log(SEV_INFO, 'Importing module ' .. module_name .. '(' .. module_world_id .. ')') import_or_upgrade(module_world_id, module_name, user) Log(SEV_INFO, 'Import complete') end Trigger module_upgrade(module_world_id, module_name, user) Log(SEV_INFO, 'Upgrading module ' .. module_name .. '(' .. module_world_id .. ')') import_or_upgrade(module_world_id, module_name, user) Log(SEV_INFO, 'Upgrade complete') end Trigger module_unimport(module_world_id, module_name, user) Log(SEV_INFO, 'Unimporting module ' .. module_name .. '(' .. module_world_id .. ')') Log(SEV_INFO, 'No actions taken') end -- Local functions function import_or_upgrade(module_world_id, module_name, user) local user_name = 'Metaplace (system)' if (user ~= nil) then user_name = user.name end Log(SEV_INFO, 'Executing in the context of ' .. user_name) -- Attach player scripts safe_attach_script(PLAYER_TEMPLATE, PLAYER_AVATAR_SCRIPT) safe_attach_script(PLAYER_TEMPLATE, PLAYER_AVATAR_MOVE_SCRIPT) safe_attach_script(PLAYER_TEMPLATE, PLAYER_AVATAR_CUSTOMIZATION_SCRIPT) end function safe_attach_script(template_id, script_id, test_object) local safe_to_attach = 1 if (test_object ~= nil) then if (HasScriptById(test_object, script_id) == 1) then safe_to_attach = 0 end end if (safe_to_attach ~= 0) then Log(SEV_INFO, 'Attaching script ' .. script_id .. ' to template ' .. template_id) local result = stylesheet.AttachTemplateScript(template_id, script_id) if (result ~= true) then Log(SEV_INFO, 'An error was encountered. ' .. 'The most likely cause is that the script was already attached, and this error can be safely ignored.') end end end