| Code: known_ids = {} known_sessions = {} tp_started = false tp_retry = false avatars_colors = {} colors = {"red","green","blue","yellow","magenta","cyan","orange","purple","pink"}
-- Here, we define a custom set of side bar buttons for performing useful -- tasks or opening commonly used floaters that do not have an associated -- toolbar button. -- We also perform tasks that can only happen after successful login. function OnLogin(location) -- Setup the sidebar SideBarHideOnRightClick() SideBarHide(false) SideBarButton(1, "inv_item_landmark_visited.tga", "OpenFloater('teleport history')", "Opens the Teleport history") SideBarButton(2, "inv_item_settings.tga", "OpenFloater('preferences')", "Opens the Preferences floater") SideBarButton(3, "43f0a590-f3d3-48b5-b460-f5b3e6e03626.tga", "OpenFloater('sounds list')", "Opens the Sounds list floater") SideBarButton(4, "inv_folder_clothing.tga","OpenLuaFloater('inventory');SetLuaFloaterValue('inventory','inventory1', 'My Outfits')", "Opens outfits folder") -- Define the Lua pie menu for avatars DefineAvatarPieMenu() end
-- This callback is invoked each time the side bar visibility is changed. We -- use it to display the Lua icon in the status bar whenever the side bar gets -- hidden and we setup the command for that icon so that, when clicked, it -- shows the side bar (which in turn hides the status bar icon via this -- callback). function OnSideBarVisibilityChange(visible) if visible then StatusBarLuaIcon("") else StatusBarLuaIcon("SideBarHide(false)", "Shows the Lua buttons side bar") end end
-- Here we add pseudo commands to: -- * emulate Firestorm's "/dd" (draw distance) command (with "/dd" alone as an -- alias for "/dd 256"); -- * toggle the camera front view with "/fc"; -- * adjust the avatar Z offset with "/z " followed by a amount of centimeters -- (e.g.: "/z -8" to lower your avatar height by 8 cm), with "/z" alone to reset -- the offset to zero. function OnSendChat(text) if string.sub(text, 1, 1) ~= "/" then -- Do not waste time searching for commands if the first character is -- not a slash... return text end if text == "/fc" then SetDebugSetting("CameraFrontView", not GetDebugSetting("CameraFrontView")) return "" end if text == "/dd" then SetDebugSetting("RenderFarClip", 256) return "" end local i, j = string.find(text, "/dd ") if i == 1 then local distance = tonumber(string.sub(text, j + 1)) if distance > 512 then distance = 512 elseif distance < 32 then distance = 32 end SetDebugSetting("RenderFarClip", distance) return "" end if text == "/z" then SetDebugSetting("AvatarOffsetZ", 0) return "" end i, j = string.find(text, "/z ") if i == 1 then local offset = tonumber(string.sub(text, j + 1)) / 100 if offset > 9 then offset = 9 elseif offset < -9 then offset = 9 end SetDebugSetting("AvatarOffsetZ", offset) return "" end end
function OnLuaDialogClose(title, button, text) if title == "Retry TP" and button == 3 then max_agent = tonumbe(text) if max_agent > 0 then tp_retry = true OverlayBarLuaButton("Cancel auto-TP", "AutomationMessage('cancel-auto-tp')") end end end
function OnFailedTPSimChange(agents, x, y, z) if tp_retry and agents < max_agents then TeleportAgentToPos(x, y, z) OverlayBarLuaButton("", "") end end
-- Here is an example of how to use the Lua pie menu, the mini-map and tag -- colors, and the OnAvatarRezzing() callback. -- This defines an avatar pie menu with colors you can set for the corresponding -- avatar's dot in the mini-map and name tag. The color is remembered during the -- session, even if the avatar gets de-rezzed and re-rezzed. function DefineAvatarPieMenu() LuaPieMenuSlice(4, 1, "Blue", "nop") LuaPieMenuSlice(4, 2, "Cyan", "nop") LuaPieMenuSlice(4, 3, "Red", "nop") LuaPieMenuSlice(4, 4, "Magenta", "nop") LuaPieMenuSlice(4, 5, "Yellow", "nop") LuaPieMenuSlice(4, 6, "White", "nop") LuaPieMenuSlice(4, 7, "Default", "nop") LuaPieMenuSlice(4, 8, "Green", "nop") end
function OnLuaPieMenu(data) local color = "" if data.slice == 1 then color = "blue" elseif data.slice == 2 then color = "cyan" elseif data.slice == 3 then color = "red" elseif data.slice == 4 then color = "magenta" elseif data.slice == 5 then color = "yellow" elseif data.slice == 6 then color = "white" elseif data.slice == 8 then color = "green" end avatars_colors[data.object_id] = color SetAvatarMinimapColor(data.object_id, color) SetAvatarNameTagColor(data.object_id, color) end
function OnChatTextColoring(id, name, text) local color = avatars_colors[id] local randomInt if IsAgentFriend(id) then --if color then --check if your friend have an pre-assigned color -- return color --else SetAvatarMinimapColor(id,"0.4,1.0,0.2") SetAvatarNameTagColor(id,"0.4,1.0,0.2") return "0.4,1.0,0.2" --Friends default color --end end return "" end
function OnRegionChange(region) avatars_colors = {} end
function OnAvatarRezzing(id) local color = avatars_colors[id] if color then SetAvatarMinimapColor(id, color) SetAvatarNameTagColor(id, color) end if IsAgentFriend(id) then if color then --check if your friend have an pre-assigned color return color else SetAvatarMinimapColor(id, "0.4,1.0,0.2") SetAvatarNameTagColor(id, "0.4,1.0,0.2") return "0.4,1.0,0.2" --Friends default color end end end known_sessions = {}
function OnInstantMsg(session_id, origin_id, session_type, name, text) if session_type == 0 then PlayUISound("NewIncomingIMSession") --OpenNotification(0,name .. text) end -- If it is not a conference session or it already got dealt with, do not care if session_type ~= 2 or known_sessions[session_id] then return end -- Flag this new conference session as already dealt with known_sessions[session_id] = true -- If not initiated by a friend, close the session and mute the initiator -- NOTE: OnInstantMsg() always receives the legacy name in 'name' if not IsAgentFriend(name) then CloseIMSession(session_id) AddMute(name) -- Depending on viewer configuration, the name may get any "Resident" -- last name stripped off. Since we mute the initiator by name (because -- their UUID is sadly not passed to the viewer by the server when a -- conference IM is initiated), we must ensure that any new resident -- who got "Resident" as their last name for their avatar (case of all -- the griefers that register new avatars) have both "Firstname" and -- "Firstname Resident" registered in our mute list... if not string.find(name, " ") then -- There is no last name, so "name" is "Firstname" and we must add -- "Firstname Resident". AddMute(name .. " Resident") else local i = string.find(name, " Resident") if i then -- "name" is "Firstname Resident" and we must add "Firstname". AddMute(string.sub(name, 1, i - 1)) end end end end
| |