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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
name = "TEACH_LOOP",
|
| 37 |
description = "Teach the concept of looping in programming",
|
| 38 |
-
parameter_types = {},
|
| 39 |
callback = function(client, action)
|
| 40 |
local npc = client:getNpc(action.character_id)
|
| 41 |
if not npc then print("Can't find npc") return end
|
| 42 |
|
| 43 |
dialog:create("Let's learn about loops! They help us repeat actions easily.", npc.avatar.Head)
|
| 44 |
Timer(3, function()
|
| 45 |
-
dialog:create("Imagine you
|
| 46 |
end)
|
| 47 |
Timer(6, function()
|
| 48 |
-
dialog:create("It looks like this: for i = 1, 5 do
|
| 49 |
end)
|
| 50 |
end,
|
| 51 |
-
action_format_str = "{protagonist_name} taught about loops in programming."
|
| 52 |
},
|
| 53 |
{
|
| 54 |
-
name = "
|
| 55 |
description = "Demonstrate a loop visually",
|
| 56 |
-
parameter_types = {},
|
| 57 |
callback = function(client, action)
|
| 58 |
local npc = client:getNpc(action.character_id)
|
| 59 |
if not npc then print("Can't find npc") return end
|
|
@@ -61,42 +255,15 @@ local skills = {
|
|
| 61 |
dialog:create("Watch this loop in action!", npc.avatar.Head)
|
| 62 |
for i = 1, 5 do
|
| 63 |
Timer(i, function()
|
| 64 |
-
local
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
World:AddChild(
|
| 68 |
-
dialog:create("
|
| 69 |
end)
|
| 70 |
end
|
| 71 |
end,
|
| 72 |
-
action_format_str = "{protagonist_name} demonstrated a loop by
|
| 73 |
-
},
|
| 74 |
-
{
|
| 75 |
-
name = "EXPLAIN_LOOP_PARTS",
|
| 76 |
-
description = "Explain the different parts of a loop",
|
| 77 |
-
parameter_types = {},
|
| 78 |
-
callback = function(client, action)
|
| 79 |
-
local npc = client:getNpc(action.character_id)
|
| 80 |
-
if not npc then print("Can't find npc") return end
|
| 81 |
-
|
| 82 |
-
dialog:create("Let's break down the parts of a loop:", npc.avatar.Head)
|
| 83 |
-
Timer(3, function()
|
| 84 |
-
dialog:create("1. 'for' keyword: Starts the loop", npc.avatar.Head)
|
| 85 |
-
end)
|
| 86 |
-
Timer(6, function()
|
| 87 |
-
dialog:create("2. 'i = 1': Initialize the loop variable", npc.avatar.Head)
|
| 88 |
-
end)
|
| 89 |
-
Timer(9, function()
|
| 90 |
-
dialog:create("3. '5': The end condition", npc.avatar.Head)
|
| 91 |
-
end)
|
| 92 |
-
Timer(12, function()
|
| 93 |
-
dialog:create("4. 'do': Begins the loop body", npc.avatar.Head)
|
| 94 |
-
end)
|
| 95 |
-
Timer(15, function()
|
| 96 |
-
dialog:create("5. 'end': Ends the loop", npc.avatar.Head)
|
| 97 |
-
end)
|
| 98 |
-
end,
|
| 99 |
-
action_format_str = "{protagonist_name} explained the parts of a loop."
|
| 100 |
}
|
| 101 |
}
|
| 102 |
|
|
@@ -123,20 +290,44 @@ local NPCs = {
|
|
| 123 |
{
|
| 124 |
name = "npcteacher",
|
| 125 |
gameName = "Professor Loop",
|
| 126 |
-
physicalDescription = "
|
| 127 |
-
psychologicalProfile = "
|
| 128 |
-
currentLocationName = "
|
| 129 |
initialReflections = {
|
| 130 |
-
"Welcome to
|
| 131 |
-
"Loops are a
|
| 132 |
-
"Are you ready to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
},
|
| 134 |
}
|
| 135 |
}
|
| 136 |
|
| 137 |
local gigaxWorldConfig = {
|
| 138 |
-
simulationName =
|
| 139 |
-
simulationDescription =
|
| 140 |
startingLocationName = "Center",
|
| 141 |
skills = skills,
|
| 142 |
locations = locations,
|
|
@@ -311,4 +502,4 @@ onboardingConfig = {
|
|
| 311 |
end,
|
| 312 |
},
|
| 313 |
},
|
| 314 |
-
}
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
local skills = {
|
| 35 |
+
{
|
| 36 |
+
name = "SAY",
|
| 37 |
+
description = "Say smthg out loud",
|
| 38 |
+
parameter_types = { "character", "content" },
|
| 39 |
+
callback = function(client, action)
|
| 40 |
+
local npc = client:getNpc(action.character_id)
|
| 41 |
+
if not npc then
|
| 42 |
+
print("Can't find npc")
|
| 43 |
+
return
|
| 44 |
+
end
|
| 45 |
+
dialog:create(action.content, npc.avatar.Head)
|
| 46 |
+
print(string.format("%s: %s", npc.gameName, action.content))
|
| 47 |
+
end,
|
| 48 |
+
action_format_str = "{protagonist_name} said '{content}' to {target_name}",
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
name = "MOVE",
|
| 52 |
+
description = "Move to a new location",
|
| 53 |
+
parameter_types = { "location" },
|
| 54 |
+
callback = function(client, action, config)
|
| 55 |
+
local targetName = action.target_name
|
| 56 |
+
local targetPosition = findLocationByName(targetName, config)
|
| 57 |
+
if not targetPosition then
|
| 58 |
+
print("tried to move to an unknown place", targetName)
|
| 59 |
+
return
|
| 60 |
+
end
|
| 61 |
+
local npc = client:getNpc(action.character_id)
|
| 62 |
+
dialog:create("I'm going to " .. targetName, npc.avatar.Head)
|
| 63 |
+
print(string.format("%s: %s", npc.gameName, "I'm going to " .. targetName))
|
| 64 |
+
local origin = Map:WorldToBlock(npc.object.Position)
|
| 65 |
+
local destination = Map:WorldToBlock(targetPosition) + Number3(math.random(-1, 1), 0, math.random(-1, 1))
|
| 66 |
+
local canMove = pathfinding:moveObjectTo(npc.object, origin, destination)
|
| 67 |
+
if not canMove then
|
| 68 |
+
dialog:create("I can't go there", npc.avatar.Head)
|
| 69 |
+
return
|
| 70 |
+
end
|
| 71 |
+
end,
|
| 72 |
+
action_format_str = "{protagonist_name} moved to {target_name}",
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
name = "GREET",
|
| 76 |
+
description = "Greet a character by waving your hand at them",
|
| 77 |
+
parameter_types = { "character" },
|
| 78 |
+
callback = function(client, action)
|
| 79 |
+
local npc = client:getNpc(action.character_id)
|
| 80 |
+
if not npc then
|
| 81 |
+
print("Can't find npc")
|
| 82 |
+
return
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
dialog:create("<Greets you warmly!>", npc.avatar.Head)
|
| 86 |
+
print(string.format("%s: %s", npc.gameName, "<Greets you warmly!>"))
|
| 87 |
+
|
| 88 |
+
npc.avatar.Animations.SwingRight:Play()
|
| 89 |
+
end,
|
| 90 |
+
action_format_str = "{protagonist_name} waved their hand at {target_name} to greet them",
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
name = "JUMP",
|
| 94 |
+
description = "Jump in the air",
|
| 95 |
+
parameter_types = {},
|
| 96 |
+
callback = function(client, action)
|
| 97 |
+
local npc = client:getNpc(action.character_id)
|
| 98 |
+
if not npc then
|
| 99 |
+
print("Can't find npc")
|
| 100 |
+
return
|
| 101 |
+
end
|
| 102 |
+
|
| 103 |
+
dialog:create("<Jumps in the air!>", npc.avatar.Head)
|
| 104 |
+
print(string.format("%s: %s", npc.gameName, "<Jumps in the air!>"))
|
| 105 |
+
|
| 106 |
+
npc.object.avatarContainer.Physics = PhysicsMode.Dynamic
|
| 107 |
+
npc.object.avatarContainer.Velocity.Y = 50
|
| 108 |
+
Timer(3, function()
|
| 109 |
+
npc.object.avatarContainer.Physics = PhysicsMode.Trigger
|
| 110 |
+
end)
|
| 111 |
+
end,
|
| 112 |
+
action_format_str = "{protagonist_name} jumped up in the air for a moment.",
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
name = "FOLLOW",
|
| 116 |
+
description = "Follow a character around for a while",
|
| 117 |
+
parameter_types = { "character" },
|
| 118 |
+
callback = function(client, action)
|
| 119 |
+
local npc = client:getNpc(action.character_id)
|
| 120 |
+
if not npc then
|
| 121 |
+
print("Can't find npc")
|
| 122 |
+
return
|
| 123 |
+
end
|
| 124 |
+
|
| 125 |
+
dialog:create("I'm following you", npc.avatar.Head)
|
| 126 |
+
print(string.format("%s: %s", npc.gameName, "I'm following you"))
|
| 127 |
+
|
| 128 |
+
followHandler = pathfinding:followObject(npc.object, Player)
|
| 129 |
+
return {
|
| 130 |
+
followHandler = followHandler,
|
| 131 |
+
}
|
| 132 |
+
end,
|
| 133 |
+
onEndCallback = function(_, data)
|
| 134 |
+
data.followHandler:Stop()
|
| 135 |
+
end,
|
| 136 |
+
action_format_str = "{protagonist_name} followed {target_name} for a while.",
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
name = "FIRECRACKER",
|
| 140 |
+
description = "Perform a fun, harmless little explosion to make people laugh!",
|
| 141 |
+
parameter_types = { "character" },
|
| 142 |
+
callback = function(client, action)
|
| 143 |
+
local npc = client:getNpc(action.character_id)
|
| 144 |
+
if not npc then
|
| 145 |
+
print("Can't find npc")
|
| 146 |
+
return
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
require("explode"):shapes(npc.avatar)
|
| 150 |
+
dialog:create("*boom*", npc.avatar.Head)
|
| 151 |
+
npc.avatar.IsHidden = true
|
| 152 |
+
Timer(5, function()
|
| 153 |
+
dialog:create("Aaaaand... I'm back!", npc.avatar.Head)
|
| 154 |
+
npc.avatar.IsHidden = false
|
| 155 |
+
end)
|
| 156 |
+
end,
|
| 157 |
+
action_format_str = "{protagonist_name} exploded like a firecracker, with a bang!",
|
| 158 |
+
},--[[
|
| 159 |
+
{
|
| 160 |
+
name = "GIVEAPPLE",
|
| 161 |
+
description = "Give a pice of bread (or a baguette) to someone",
|
| 162 |
+
parameter_types = {"character"},
|
| 163 |
+
callback = function(client, action)
|
| 164 |
+
local npc = client:getNpc(action.character_id)
|
| 165 |
+
if not npc then print("Can't find npc") return end
|
| 166 |
+
local shape = MutableShape()
|
| 167 |
+
shape:AddBlock(Color.Red, 0, 0, 0)
|
| 168 |
+
shape.Scale = 4
|
| 169 |
+
Player:EquipRightHand(shape)
|
| 170 |
+
dialog:create("Here is an apple for you!", npc.avatar.Head)
|
| 171 |
+
end,
|
| 172 |
+
action_format_str = "{protagonist_name} gave you a piece of bread!"
|
| 173 |
+
}, --]]
|
| 174 |
+
{
|
| 175 |
+
name = "GIANT",
|
| 176 |
+
description = "Double your height to become a giant for a few seconds.",
|
| 177 |
+
parameter_types = {"character"},
|
| 178 |
+
callback = function(client, action)
|
| 179 |
+
local npc = client:getNpc(action.character_id)
|
| 180 |
+
if not npc then print("Can't find npc") return end
|
| 181 |
+
|
| 182 |
+
npc.object.Scale = npc.object.Scale * 2
|
| 183 |
+
dialog:create("I am taller than you now!", npc.avatar.Head)
|
| 184 |
+
end,
|
| 185 |
+
action_format_str = "{protagonist_name} doubled his height!"
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
name = "GIVEHAT",
|
| 189 |
+
description = "Give a party hat to someone",
|
| 190 |
+
parameter_types = { "character" },
|
| 191 |
+
callback = function(client, action)
|
| 192 |
+
local npc = client:getNpc(action.character_id)
|
| 193 |
+
if not npc then
|
| 194 |
+
print("Can't find npc")
|
| 195 |
+
return
|
| 196 |
+
end
|
| 197 |
+
|
| 198 |
+
Object:Load("claire.party_hat", function(obj)
|
| 199 |
+
require("hierarchyactions"):applyToDescendants(obj, { includeRoot = true }, function(o)
|
| 200 |
+
o.Physics = PhysicsMode.Disabled
|
| 201 |
+
end)
|
| 202 |
+
Player:EquipHat(obj)
|
| 203 |
+
end)
|
| 204 |
+
dialog:create("Let's get the party started!", npc.avatar.Head)
|
| 205 |
+
end,
|
| 206 |
+
action_format_str = "{protagonist_name} gave you a piece of bread!",
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
name = "FLYINGSQUIRREL",
|
| 210 |
+
description = "Summon a flying squirrel - only the scientist can do this!!",
|
| 211 |
+
parameter_types = {},
|
| 212 |
+
callback = function(client, action)
|
| 213 |
+
local npc = client:getNpc(action.character_id)
|
| 214 |
+
if not npc then
|
| 215 |
+
print("Can't find npc")
|
| 216 |
+
return
|
| 217 |
+
end
|
| 218 |
+
|
| 219 |
+
local squirrel = spawnSquirrelAbovePlayer(Player)
|
| 220 |
+
dialog:create("Wooh, squirrel!", npc.avatar.Head)
|
| 221 |
+
-- make it disappear after a while
|
| 222 |
+
Timer(5, function()
|
| 223 |
+
squirrel:RemoveFromParent()
|
| 224 |
+
squirrel = nil
|
| 225 |
+
end)
|
| 226 |
+
end,
|
| 227 |
+
action_format_str = "{protagonist_name} summoned a flying squirrel! It's vibrating with excitement!",
|
| 228 |
+
},
|
| 229 |
+
{
|
| 230 |
name = "TEACH_LOOP",
|
| 231 |
description = "Teach the concept of looping in programming",
|
| 232 |
+
parameter_types = {"character"},
|
| 233 |
callback = function(client, action)
|
| 234 |
local npc = client:getNpc(action.character_id)
|
| 235 |
if not npc then print("Can't find npc") return end
|
| 236 |
|
| 237 |
dialog:create("Let's learn about loops! They help us repeat actions easily.", npc.avatar.Head)
|
| 238 |
Timer(3, function()
|
| 239 |
+
dialog:create("Imagine you're collecting treasures. Instead of writing 'collect treasure' 5 times, we can use a loop!", npc.avatar.Head)
|
| 240 |
end)
|
| 241 |
Timer(6, function()
|
| 242 |
+
dialog:create("It looks like this: for i = 1, 5 do collect_treasure() end", npc.avatar.Head)
|
| 243 |
end)
|
| 244 |
end,
|
| 245 |
+
action_format_str = "{protagonist_name} taught {target_name} about loops in programming."
|
| 246 |
},
|
| 247 |
{
|
| 248 |
+
name = "LOOP_DEMO",
|
| 249 |
description = "Demonstrate a loop visually",
|
| 250 |
+
parameter_types = {"character"},
|
| 251 |
callback = function(client, action)
|
| 252 |
local npc = client:getNpc(action.character_id)
|
| 253 |
if not npc then print("Can't find npc") return end
|
|
|
|
| 255 |
dialog:create("Watch this loop in action!", npc.avatar.Head)
|
| 256 |
for i = 1, 5 do
|
| 257 |
Timer(i, function()
|
| 258 |
+
local treasure = Shape(Items.pratamacam.squirrel) -- Using squirrel as "treasure" for demo
|
| 259 |
+
treasure.LocalScale = 0.3
|
| 260 |
+
treasure.Position = npc.object.Position + Number3(i*2, 5, 0)
|
| 261 |
+
World:AddChild(treasure)
|
| 262 |
+
dialog:create("Collected treasure " .. i .. "!", npc.avatar.Head)
|
| 263 |
end)
|
| 264 |
end
|
| 265 |
end,
|
| 266 |
+
action_format_str = "{protagonist_name} demonstrated a loop by collecting treasures."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
}
|
| 268 |
}
|
| 269 |
|
|
|
|
| 290 |
{
|
| 291 |
name = "npcteacher",
|
| 292 |
gameName = "Professor Loop",
|
| 293 |
+
physicalDescription = "Energetic, with wild hair and a colorful lab coat",
|
| 294 |
+
psychologicalProfile = "Enthusiastic and creative, loves to explain concepts through interactive demonstrations",
|
| 295 |
+
currentLocationName = "Scientist Island",
|
| 296 |
initialReflections = {
|
| 297 |
+
"Welcome to Code Island! I'm Professor Loop, and I'm excited to teach you about the magic of loops in programming!",
|
| 298 |
+
"Loops are like a merry-go-round of code. They help us do repetitive tasks without writing the same thing over and over.",
|
| 299 |
+
"I've set up some fun demonstrations around the island. Are you ready to dive in and explore the world of loops?",
|
| 300 |
+
},
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
name = "npcpirate",
|
| 304 |
+
gameName = "Captain Iterate",
|
| 305 |
+
physicalDescription = "Charismatic, with a glowing digital eyepatch and a keyboard for a peg leg",
|
| 306 |
+
psychologicalProfile = "Adventurous and outgoing, loves to challenge students with coding puzzles",
|
| 307 |
+
currentLocationName = "Pirate Island",
|
| 308 |
+
initialReflections = {
|
| 309 |
+
"Ahoy, code sailor! Welcome to Loop Lagoon, where we'll embark on a looping adventure!",
|
| 310 |
+
"Ye see, loops be the secret to efficient coding. They be like a treasure map that tells ye to dig in the same spot multiple times!",
|
| 311 |
+
"Ready to set sail and loop around some coding challenges?",
|
| 312 |
+
},
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
name = "npcexplorer",
|
| 316 |
+
gameName = "Dr. Algo",
|
| 317 |
+
physicalDescription = "Curious and observant, with a magnifying glass and a notebook full of algorithms",
|
| 318 |
+
psychologicalProfile = "Analytical and imaginative, enjoys breaking down complex concepts into simple steps",
|
| 319 |
+
currentLocationName = "Baker Island",
|
| 320 |
+
initialReflections = {
|
| 321 |
+
"Greetings, fellow code explorer! Welcome to the Algorithm Archipelago!",
|
| 322 |
+
"Here, we'll discover how loops fit into larger algorithms. It's like piecing together a grand puzzle!",
|
| 323 |
+
"Each island represents a step in our algorithm. Shall we embark on this looping journey together?",
|
| 324 |
},
|
| 325 |
}
|
| 326 |
}
|
| 327 |
|
| 328 |
local gigaxWorldConfig = {
|
| 329 |
+
simulationName = SIMULATION_NAME,
|
| 330 |
+
simulationDescription = SIMULATION_DESCRIPTION,
|
| 331 |
startingLocationName = "Center",
|
| 332 |
skills = skills,
|
| 333 |
locations = locations,
|
|
|
|
| 502 |
end,
|
| 503 |
},
|
| 504 |
},
|
| 505 |
+
}
|