Advertisement
Guest User

Untitled

a guest
May 5th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer controller_channel = -982742;
  2.  
  3. string current_scene = "";
  4. // RGB
  5. list scenes;
  6.  
  7. load_scene(string name)
  8. {
  9.     integer scene_index = llListFindList(scenes, [name]);
  10.     if (scene_index == -1) return; // No such scene.
  11.     list settings_point_light = llList2List(scenes, scene_index + 1, scene_index + 6);
  12.     llSay(0, "settings_point_light" + llList2CSV(settings_point_light));
  13.     list settings_glow = llList2List(scenes, scene_index + 7, scene_index + 7);
  14.     llSay(0, "settings_glow: " + llList2CSV(settings_glow));
  15.     list settings_fullbright = llList2List(scenes, scene_index + 8, scene_index + 8);
  16.     llSay(0, "settings_fullbright: " + llList2CSV(settings_fullbright));
  17.     llSetLinkPrimitiveParams(LINK_THIS, [PRIM_POINT_LIGHT] + settings_point_light + [ PRIM_GLOW, ALL_SIDES ] + settings_glow + [ PRIM_FULLBRIGHT, ALL_SIDES] + settings_fullbright);
  18.     current_scene = name;
  19. }
  20.  
  21. save_scene(string name)
  22. {
  23.     // Check if the list already contains scene.
  24.     integer scene_index = llListFindList(scenes, [name]);
  25.     if (scene_index != -1)
  26.     {
  27.         // The scene already exists. Remove the existing.
  28.         // PRIM_POINT_LIGHT has 5 properties, PRIM_GLOW has one, as does prim_fullbright, a total of 7 properties
  29.         scenes = llDeleteSubList(scenes, scene_index, scene_index + 8);
  30.  
  31.     }
  32.     // Get the current lighting setup
  33.     list settings = llGetLinkPrimitiveParams(LINK_THIS, [PRIM_POINT_LIGHT,PRIM_GLOW, ALL_SIDES,PRIM_FULLBRIGHT, ALL_SIDES]);
  34.     scenes += [name] + settings;
  35.     llSay(0, "save scene '" + name + "' w/ settings " + llList2CSV(settings));
  36. }
  37.  
  38. default
  39. {
  40.     state_entry()
  41.     {
  42.         llListen(controller_channel, "", NULL_KEY, "");
  43.     }
  44.  
  45.     listen(integer channel, string name, key id, string message)
  46.     {
  47.         if (llGetOwnerKey(id) != llGetOwner()) return; // someone else's
  48.         list params = llCSV2List(message);
  49.         string cmd  = llList2String(params, 0);
  50.         string scene_name = llList2String(params, 1);
  51.         if (cmd == "save_scene")
  52.         {
  53.             save_scene(scene_name);
  54.         }
  55.         if (cmd == "load_scene")
  56.         {
  57.             load_scene(scene_name);
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement