-- makefile - UI Library Installation file -- Author: Jeff the Intern -- Revisions -- New Script - 08/01/08 - J.McNab -- 08/04/2008 P.Ferland - Improved resilience of import/upgrade process -- 09/25/2008 P.Ferland - Reworked import/upgrade path to function with no user context -- Constants -- Constants PLAYER_UI_SCRIPT = '13197:23' 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, 'No actions taken') 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) -- Register profile script safe_attach_script(PLAYER_TEMPLATE, PLAYER_UI_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