Corentin Cailleaud commited on
Commit
6ababa9
1 Parent(s): c9aae36
Files changed (1) hide show
  1. cubzh.lua +53 -91
cubzh.lua CHANGED
@@ -2,6 +2,7 @@ Modules = {
2
  --gigax = "github.com/GigaxGames/integrations/cubzh:5025b99",
3
  pathfinding = "github.com/caillef/cubzh-library/pathfinding:f8c4315",
4
  floating_island_generator = "github.com/caillef/cubzh-library/floating_island_generator:82d22a5",
 
5
  }
6
 
7
  Config = {
@@ -10,96 +11,6 @@ Config = {
10
 
11
  math.randomseed(math.floor(Time.UnixMilli() % 100000))
12
 
13
- local easy_onboarding = {}
14
-
15
- local currentStep = 0
16
- local steps = {}
17
- local stopCallbackData
18
-
19
- easy_onboarding.startOnboarding = function(self, config)
20
- currentStep = 1
21
- steps = config.steps
22
- stopCallbackData = steps[1].start(self, currentStep)
23
- end
24
-
25
- easy_onboarding.createTextStep = function(_, str)
26
- local ui = require("uikit")
27
- local node = ui:createFrame(Color(0, 0, 0, 0.5))
28
- local text = ui:createText(str, Color.White)
29
- text:setParent(node)
30
- node.parentDidResize = function()
31
- node.Width = text.Width + text.Height
32
- node.Height = text.Height * 2
33
- text.pos = { node.Width * 0.5 - text.Width * 0.5, node.Height * 0.5 - text.Height * 0.5 }
34
- node.pos = { Screen.Width * 0.5 - node.Width * 0.5, Screen.Height * 0.2 - node.Height * 0.5 }
35
- end
36
- node:parentDidResize()
37
- return node
38
- end
39
-
40
- easy_onboarding.next = function(self)
41
- if not steps[currentStep] then
42
- return
43
- end
44
- steps[currentStep].stop(self, stopCallbackData)
45
- currentStep = currentStep + 1
46
- if not steps[currentStep] then
47
- return
48
- end
49
- stopCallbackData = steps[currentStep].start(self, currentStep)
50
- end
51
-
52
- local onboardingConfig = {
53
- steps = {
54
- {
55
- start = function(onboarding)
56
- local data = {}
57
- data.ui = onboarding:createTextStep("1/3 - Hold click and drag to move the camera.")
58
- data.listener = LocalEvent:Listen(LocalEvent.Name.PointerDrag, function()
59
- Timer(1, function()
60
- onboarding:next()
61
- end)
62
- data.listener:Remove()
63
- end)
64
- return data
65
- end,
66
- stop = function(_, data)
67
- data.ui:remove()
68
- end,
69
- },
70
- {
71
- start = function(onboarding)
72
- local data = {}
73
- data.ui = onboarding:createTextStep("2/3 - Use WASD/ZQSD to move")
74
- data.listener = LocalEvent:Listen(LocalEvent.Name.KeyboardInput, function()
75
- Timer(1, function()
76
- onboarding:next()
77
- end)
78
- data.listener:Remove()
79
- end)
80
-
81
- return data
82
- end,
83
- stop = function(_, data)
84
- data.ui:remove()
85
- end,
86
- },
87
- {
88
- start = function(onboarding)
89
- local data = {}
90
- data.ui = onboarding:createTextStep("3/3 - Press Enter in front of a NPC to chat")
91
- Timer(10, function()
92
- onboarding:next()
93
- end)
94
- return data
95
- end,
96
- stop = function(_, data)
97
- data.ui:remove()
98
- end,
99
- },
100
- },
101
- }
102
-
103
  Config = {
104
  Items = { "pratamacam.squirrel" },
105
  }
@@ -907,6 +818,57 @@ Client.OnChat = function(payload)
907
  content = msg,
908
  })
909
 
910
- print(payload.message)
911
  return true
912
  end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  --gigax = "github.com/GigaxGames/integrations/cubzh:5025b99",
3
  pathfinding = "github.com/caillef/cubzh-library/pathfinding:f8c4315",
4
  floating_island_generator = "github.com/caillef/cubzh-library/floating_island_generator:82d22a5",
5
+ easy_onboarding = "github.com/caillef/cubzh-library/easy_onboarding:77728ee",
6
  }
7
 
8
  Config = {
 
11
 
12
  math.randomseed(math.floor(Time.UnixMilli() % 100000))
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  Config = {
15
  Items = { "pratamacam.squirrel" },
16
  }
 
818
  content = msg,
819
  })
820
 
821
+ print("User: " .. payload.message)
822
  return true
823
  end
824
+
825
+ onboardingConfig = {
826
+ steps = {
827
+ {
828
+ start = function(onboarding)
829
+ local data = {}
830
+ data.ui = onboarding:createTextStep("1/3 - Hold click and drag to move the camera.")
831
+ data.listener = LocalEvent:Listen(LocalEvent.Name.PointerDrag, function()
832
+ Timer(1, function()
833
+ onboarding:next()
834
+ end)
835
+ data.listener:Remove()
836
+ end)
837
+ return data
838
+ end,
839
+ stop = function(_, data)
840
+ data.ui:remove()
841
+ end,
842
+ },
843
+ {
844
+ start = function(onboarding)
845
+ local data = {}
846
+ data.ui = onboarding:createTextStep("2/3 - Use WASD/ZQSD to move.")
847
+ data.listener = LocalEvent:Listen(LocalEvent.Name.KeyboardInput, function()
848
+ Timer(1, function()
849
+ onboarding:next()
850
+ end)
851
+ data.listener:Remove()
852
+ end)
853
+
854
+ return data
855
+ end,
856
+ stop = function(_, data)
857
+ data.ui:remove()
858
+ end,
859
+ },
860
+ {
861
+ start = function(onboarding)
862
+ local data = {}
863
+ data.ui = onboarding:createTextStep("3/3 - Press Enter in front of the Pirate to chat.")
864
+ Timer(10, function()
865
+ onboarding:next()
866
+ end)
867
+ return data
868
+ end,
869
+ stop = function(_, data)
870
+ data.ui:remove()
871
+ end,
872
+ },
873
+ },
874
+ }