diff options
Diffstat (limited to 'scripts/lua/demo.lua')
-rw-r--r-- | scripts/lua/demo.lua | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/scripts/lua/demo.lua b/scripts/lua/demo.lua new file mode 100644 index 0000000000..3442c18b0d --- /dev/null +++ b/scripts/lua/demo.lua @@ -0,0 +1,147 @@ +function popup_and_wait_ok(message) + args = {MESSAGE=message} + notif_response = nil + show_notification("GenericAlertOK", args, "notif_response") + while not notif_response do + sleep(0.2) + end + + local response = notif_response + return response +end + +function demo_environment() + popup_and_wait_ok("Change Environment") + run_ui_command("World.EnvSettings", "midnight") + sleep(2) + run_ui_command("World.EnvSettings", "sunrise") + sleep(2) + run_ui_command("World.EnvSettings", "noon") + sleep(2) +end + +function demo_rez() + for x=-1,1,1 do + for y=-1,1,1 do + rez_prim2({x,y,-1},1) + end + end +end + +function demo_avatar() + popup_and_wait_ok("Change Avatar") + + local dest = {10,10,0} + move_by(dest, "autopilot_response") + while not autopilot_response do + sleep(0.2) + end + + local response = autopilot_response + + if response == 1 then + sleep(1) + demo_rez() + sleep(2) + end + + wear_by_name("Greg") + run_ui_command("Avatar.ResetSelfSkeletonAndAnimations") + sleep(8) + + wear_by_name("Petrol Sue") + sleep(8) + + run_ui_command("Self.ToggleSitStand") + sleep(2) + run_ui_command("Self.ToggleSitStand") + sleep(2) + + --run_ui_command("View.ZoomOut") + run_ui_command("EditShape") + sleep(6) + close_floater("appearance") + +end + +function demo_ui() + + + -- adding items to 'Build' menu + -- popup_and_wait_ok("Extend UI") + + popup_and_wait_ok("UI interaction") + open_floater("inventory") + open_floater("preferences") + open_floater("nearby_chat") + nearby_chat_send("Hello World!") + + sleep(5) + close_all_floaters() + + + notif_response = nil + args = {MESSAGE="Customize the UI now?"} + show_notification("GenericAlertYesCancel", args, "notif_response") + while not notif_response do + sleep(0.2) + end + if notif_response ~= 0 then + popup_and_wait_ok("Exiting") + return + end + + menu_name = "BuildTools" + add_menu_separator(menu_name) + + params = {name="user_sit", + label="Sit!"} + params["function"]="Self.ToggleSitStand" + + add_menu_item(menu_name, params) + + params = {name="user_midnight",label="Set night",parameter="midnight"} + params["function"] = "World.EnvSettings" + + add_menu_item(menu_name, params) + + -- adding new custom menu + new_menu_name = "user_menu" + params = {name=new_menu_name,label="My Secret Menu",tear_off="true"} + add_menu(params) + + -- adding new item to the new menu + params = {name="user_debug",label="Console", + parameter="debug"} + params["function"] = "Advanced.ToggleConsole" + + add_menu_item(new_menu_name, params) + + -- adding new branch + new_branch = "user_floaters" + params = {name=new_branch, label="Open Floater",tear_off="true"} + add_branch(new_menu_name, params) + + -- adding items to the branch + params = {name="user_permissions",label="Default permissions", + parameter="perms_default"} + params["function"] = "Floater.ToggleOrBringToFront" + + + add_menu_item(new_branch, params) + + params = {name="user_beacons",label="Beacons", + parameter="beacons"} + params["function"] = "Floater.ToggleOrBringToFront" + + add_menu_item(new_branch, params) + sleep(5) + +end + +function call_once_func() + + demo_environment() + demo_avatar() + demo_ui() +end |