summaryrefslogtreecommitdiff
path: root/scripts/lua/demo.lua
blob: dc2d9ef6691e582a50aeffb66a8cac506caf2062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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_avatar()
    popup_and_wait_ok("Change Avatar")
    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("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!"},
          {"function", "Self.ToggleSitStand"}}

  add_menu_item(menu_name, params)

  params = {{"name", "user_midnight"}, {"label", "Set night"},
          {"function", "World.EnvSettings"}, {"parameter", "midnight"}}

  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"},
          {"function", "Advanced.ToggleConsole"}, {"parameter", "debug"}}

  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"},
          {"function", "Floater.ToggleOrBringToFront"}, {"parameter", "perms_default"}}

  add_menu_item(new_branch, params)

  params = {{"name", "user_beacons"}, {"label", "Beacons"},
          {"function", "Floater.ToggleOrBringToFront"}, {"parameter", "beacons"}}

  add_menu_item(new_branch, params)
  sleep(5)

end

function call_once_func()

    demo_environment()
    demo_avatar()
    demo_ui()
end