Import source (dev state between 1.2.0 and 1.3.0)
[minetest_tutorial_subgame.git] / mods / tutorial / init.lua
blobfa33e6da560698f8973f6d4c8532ba4976e73b2f
1 tutorial = {}
3 -- Saves tutorial state into file
4 function tutorial.save_state()
5 local str = minetest.serialize(tutorial.state)
6 local filepath = minetest.get_worldpath().."/tutorialdata.mt"
7 local file = io.open(filepath, "w")
8 if(file) then
9 file:write(str)
10 minetest.log("action", "[tutorial] Tutorial state has been written into "..filepath..".")
11 else
12 minetest.log("error", "[tutorial] An attempt to save the tutorial state into "..filepath.." failed.")
13 end
14 end
17 -- load tutorial state from file
19 local filepath = minetest.get_worldpath().."/tutorialdata.mt"
20 local file = io.open(filepath, "r")
21 local read = false
22 if file then
23 local string = file:read()
24 io.close(file)
25 if(string ~= nil) then
26 tutorial.state = minetest.deserialize(string)
27 minetest.log("action", "[tutorial] Tutorial state has been read from "..filepath..".")
28 read = true
29 end
30 end
31 if(read==false) then
32 tutorial.state = {}
34 -- Is this the first time the player joins this tutorial?
35 tutorial.state.first_join = true
36 -- These variables store wheather a message for those events has been shown yet.
37 tutorial.state.first_gold = false
38 tutorial.state.last_gold = false
39 tutorial.state.first_diamond = false
40 tutorial.state.last_diamond = false
41 end
43 function tutorial.register_infosign(itemstringpart, caption, fulltext)
44 minetest.register_node("tutorial:sign_"..itemstringpart, {
45 description = "Tutorial Sign '"..caption.."'",
46 drawtype = "signlike",
47 tiles = {"default_sign_wall.png"},
48 inventory_image = "default_sign_wall.png",
49 wield_image = "default_sign_wall.png",
50 paramtype = "light",
51 paramtype2 = "wallmounted",
52 sunlight_propagates = true,
53 is_ground_content = false,
54 walkable = false,
55 selection_box = { type = "wallmounted" },
56 groups = {immortal=1,attached_node=1},
57 legacy_wallmounted = true,
58 sounds = default.node_sound_defaults(),
59 on_construct = function(pos)
60 --local n = minetest.get_node(pos)
61 local meta = minetest.get_meta(pos)
62 local formspec = ""..
63 "size[12,6]"..
64 "label[-0.15,-0.4;"..caption.."]"..
65 "tablecolumns[text]"..
66 "tableoptions[background=#000000;highlight=#000000;border=false]"..
67 "table[0,0.25;12,5.2;infosign_text;"..
68 fulltext..
69 "]"..
70 "button_exit[4.5,5.5;3,1;close;Close]"
71 meta:set_string("formspec", formspec)
72 meta:set_string("infotext", "\""..caption.."\" (Right-click to read)")
73 end
75 end
79 -- Number of gold ingots/lumps
80 tutorial.gold = 13
82 -- Number of hidden diamonds
83 tutorial.diamonds = 12
85 tutorial.texts = {}
86 tutorial.texts.intro = ""..
87 "Welcome! This tutorial will teach you the most crucial basics of Minetest.,"..
88 "This tutorial assumes that you have not changed the default keybindings yet.,"..
89 ","..
90 "Let's start for the most important keybindings right now:,"..
91 ","..
92 " Look around: Move the mouse,"..
93 " Walk forwards: \\[W\\],"..
94 " Strafe left: \\[A\\],"..
95 " Walk backwards: \\[S\\],"..
96 " Strafe right: \\[D\\],"..
97 " Action: \\[Right mouse button\\],"..
98 " Pause menu (you can exit the game here): \\[Esc\\],"..
99 ","..
100 "You will find signs with more introductionary texts throughout this tutorial.,"..
101 "The \"action\" key has many uses. For now\\, let's just say you need it to read,"..
102 "the signs. Look at one and right-click it to read it.,"..
103 ","..
104 "To look at a sign\\, make sure you are close enough to it and the crosshair in the,"..
105 "center of the screen points directly on the sign.,"..
106 ","..
107 "You can exit the tutorial at any time\\, the world will be automatically saved.,"..
108 ","..
109 "Now feel free to walk around a bit and read the other signs to learn more."
111 tutorial.texts.minetest = ""..
112 "Minetest itself is not a game\\, it is a game engine.,"..
113 "To be able to actually play\\, it\\, you need something called a \"Minetest game\"\\,,"..
114 "sometimes also called \"subgame\" or just \"game\". In this tutorial\\, we use the term,"..
115 "\"subgame\".,"..
116 ","..
117 "Don't worry\\, Minetest comes pre-installed with a rather simple default subgame\\, oddly,"..
118 "also called \"Minetest\".,"..
119 ","..
120 "This tutorial teaches you the basics of Minetest (the engine)\\, things which are true for,"..
121 "all subgames. This tutorial does not teach you how to play a particular subgame\\, not,"..
122 "even the default one.,"..
123 ","..
124 "Minetest as well as the default subgame are unfinished at the moment\\, so please forgive,"..
125 "us when not everything works out perfectly."
127 tutorial.texts.subgame = ""..
128 "Now since you probably now the basics\\, you may want to actually play or build something.,"..
129 "Minetest comes bundled with a default subgame\\, which you may try out now.,"..
130 "Sadly\\, there is currently no tutorial for the default subgame.,"..
131 "You may want to read the \"Getting Started\" section of the Community Wiki\\,,"..
132 "which is more specific about the default subgame.,"..
133 "Said document can be found at:,"..
134 ","..
135 "<http://wiki.minetest.net/Getting_Started>,"..
136 ","..
137 "Alternatively\\, you may check out one of the subgames which are shared on the Minetest forums."
140 tutorial.texts.creative= ""..
141 "The creative mode is turned on. If you are here to learn how to play Minetest\\,,"..
142 "you should probably leave now\\, turn creative mode off and restart the,"..
143 "tutorial.,"..
144 ","..
145 "Roughly spoken\\, creative mode is for messing around with the game without,"..
146 "the normal gameplay restraints.,"..
147 ","..
148 "You can leave now by pressing \"Leave tutorial\"\\, or later\\, by pressing \\[Esc\\]."
150 tutorial.texts.notsingleplayer = ""..
151 "You are now playing the tutorial in multiplayer mode.,"..
152 "But this tutorial is optimized for the singleplayer mode.,"..
153 "This tutorial does not work properly with more than 1 player.,"..
154 ","..
155 "Unless you are sure no other players will join\\, you should,"..
156 "leave now and start the tutorial in singleplayer mode."
158 tutorial.texts.cam = ""..
159 "Minetest has 3 different camera modes which determine the way you see the world.,"..
160 "The three modes are:,"..
161 ","..
162 "- First-person view (default),"..
163 "- Third-person view from behind,"..
164 "- Third-person view from the front,"..
165 ","..
166 "You can change the camera mode by pressing \\[F7\\] (but you have to close this,"..
167 "window first).,"..
168 ","..
169 " Switch camera mode: \\[F7\\]"
171 tutorial.texts.blocks = ""..
172 "The world of Minetest is made entirely out of blocks\\, or cubes\\, to be precise.,"..
173 "Blocks can be added or removed with the correct tools.,"..
174 ","..
175 "In this section\\, we'll show you a few special but common blocks which behave in unexpected,"..
176 "ways.,"..
177 ","..
178 "Of course\\, subgames can come up with more special weird blocks."
180 tutorial.texts.falling_node = ""..
181 "Some blocks need to rest on top of another block\\, otherwise\\, they fall down.,"..
182 "Try it and mine the block below the uppermost block."
184 tutorial.texts.attached_node = ""..
185 "Some blocks have to be attached to another block\\, otherwise\\, they drop as an item\\,,"..
186 "as if you would have mined it.,"..
187 ","..
188 "Attached here is a picture frame. You can't collect or mine it directly\\, but if you mine,"..
189 "the block it is attached to\\, it will drop as an item which you can collect."
191 tutorial.texts.disable_jump = ""..
192 "These nasty blocks on the floor prevent you from jumping when you stand on them."
194 tutorial.texts.runover = ""..
195 "This abyss behind this sign is so small that you can even walk over it\\,,"..
196 "as long as you don't stop midway. But you can jump over it anyways\\, just to be,"..
197 "safe."
199 tutorial.texts.jumpup = ""..
200 "You can't reach this upper block by walking. But luckily\\, you are able to jump.,"..
201 "For our purposes\\, you can jump just high enough to reach one block above you.,"..
202 "But you can't two blocks high.,"..
203 "Press the space bar once to jump at a constant height.,"..
204 ","..
205 " Jump: \\[Space\\]"..
206 ","..
207 "Now try it to continue."
210 tutorial.texts.jumpover = ""..
211 "Here is a slightly larger abyss here. Luckily\\, you can also jump just far enough to,"..
212 "cross a gap of this width. Don't worry\\, the abyss is not deep enough to hurt you,"..
213 "when you fall down. There are stairs which lead back up here.,"..
214 ","..
215 " Jump: \\[Space\\]"
217 tutorial.texts.orientation = ""..
218 "From this point on\\, there will be branching paths. For orientation\\, we placed,"..
219 "some arrow signs. They just show a short text when you hover them\\, that's all.,"..
220 ","..
221 "You don't have to follow the sections in any particular order\\, with one exception\\,,"..
222 "for which you will be informed."
224 tutorial.texts.sneak = ""..
225 "Sneaking is a special move. As long as you sneak\\, you walk slower\\, but you are,"..
226 "guaranteed to not accidentally fall off the edge of a block. This also allows you to,"..
227 "\"lean over\" in a sense.,"..
228 "To sneak\\, keep the sneak key pressed. As soon as you release the sneak key\\,,"..
229 "you walk at normal speed again. Be careful not releasing the sneak key when you,"..
230 "are at a ledge\\, you might fall!,"..
231 ","..
232 " Sneak: \\[Shift\\]"..
233 ","..
234 "Keep in mind that the \\[Shift\\] key is used for a large number of other things in Minetest.,"..
235 "Sneaking only works when you are not in a liquid stand on solid ground and are not at a,"..
236 "ladder.,"..
237 ","..
238 "You may try out sneaking at this little blocky pyramid."
240 tutorial.texts.hotbar = ""..
241 "At the bottom of the screen you see 8 squares. This is called the 'hotbar'.,"..
242 "The hotbar allows you to quickly access some items from your inventory.,"..
243 "In our case\\, the upper 8 slots in your inventory.,"..
244 "You can change the selected item with the mouse wheel\\, if you have one\\, or with the,"..
245 "number keys.,"..
246 ","..
247 " Select previous item in hotbar: \\[Mouse wheel up\\],"..
248 " Select next item in hotbar: \\[Mouse wheel down\\],"..
249 " Select item #N in hotbar: the key with the number #N,"..
250 ","..
251 "The item you've seleted is also the item you wield. This will be important later for,"..
252 "tools\\, mining\\, building\\, etc."
255 tutorial.texts.eat = ""..
256 "In this chest you find some comestibles. Comestibles are items which instantly,"..
257 "heal you when eaten. This removes the item from your inventory.,"..
258 "To eat one\\, select the comestible in your hotbar\\, then click the left mouse button.,"..
259 "Unlike other items\\, you cannot punch or attack while holding a comestible. To be able,"..
260 "to attack\\, you have to select something else.,"..
261 "Of course\\, this does not have to be the only way to heal you.,"..
262 ","..
263 " Eat comestible: \\[Left mouse button\\],"..
264 ","..
265 "Don't forget to take the gold ingot."
267 tutorial.texts.chest = ""..
268 "Treasure chests are a common sight in Minetest. They are actually not built-in,"..
269 "into the game."
271 tutorial.texts.damageblock = ""..
272 "Careful! These spikes hurt you when you stand inside\\, so don't walk into them.,"..
273 "Try to walk around and get the gold ingot.,"..
274 ","..
275 "They damage you every second you stand in them.,"..
276 ","..
277 "This is one of the many ways you can get hurt in Minetest."
279 tutorial.texts.ladder = ""..
280 "This is a ladder. Ladders help you to climb up great heights or to climb down safely.,"..
281 "To climb a ladder\\, go into the block occupied by the ladder and hold one of the,"..
282 "following keys:,"..
283 ","..
284 " Climb up ladder: \\[Space\\],"..
285 " Climb down ladder: \\[Shift\\],"..
286 ","..
287 "Note that sneaking and jumping do not work when you are at a ladder."
289 tutorial.texts.swim = ""..
290 "What you see here is a small swimming pool. You are able to swim and dive.,"..
291 "Diving usually costs you breath. While diving\\, 10 bubbles appear in the heads-up display.,"..
292 "These bubbles disappear over time while diving and when you are out of bubbles\\,,"..
293 "you slowly lose some health points. You have to back up to the surface from time to,"..
294 "time to restore the bubbles.,"..
295 ","..
296 "Movement in a liquid is slightly different than on solid ground:,"..
297 ","..
298 " Swim forwards: \\[W\\],"..
299 " Swim backwards: \\[S\\],"..
300 " Swim leftwards: \\[A\\],"..
301 " Swim rightwards: \\[D\\],"..
302 " Swim upwards: \\[Space\\],"..
303 " Swim downwards: \\[Shift\\],"..
304 ","..
305 "At the bottom of the pool lies a gold ingot. Try to get it!"
308 tutorial.texts.dive = ""..
309 "To get to the other side\\, you have to dive here. Don't worry\\, the tunnel is not,"..
310 "long. But don't stay too long in the water\\, or else you take damage.,"..
311 "At the bottom of the pool lies a gold ingot. Try to get it!,"..
312 ","..
313 " Swim forwards: \\[W\\],"..
314 " Swim backwards: \\[S\\],"..
315 " Swim leftwards: \\[A\\],"..
316 " Swim rightwards: \\[D\\],"..
317 " Swim upwards: \\[Space\\],"..
318 " Swim downwards: \\[Shift\\]"
320 tutorial.texts.waterfall = ""..
321 "You can easily swim up this waterfall. Go into the water and hold the space bar until you're,"..
322 "at the top."..
323 ","..
324 " Swim forwards: \\[W\\],"..
325 " Swim backwards: \\[S\\],"..
326 " Swim leftwards: \\[A\\],"..
327 " Swim rightwards: \\[D\\],"..
328 " Swim upwards: \\[Space\\],"..
329 " Swim downwards: \\[Shift\\]"
331 tutorial.texts.liquidtypes = ""..
332 "Liquids behave somewhat weirdly Minetest. Actually\\, there are 2 kinds of liquids.,"..
333 "If you watched the waterfall closely\\, you may have noticed that there is a slight difference,"..
334 "between the water blocks that make the waterfall\\, and those up here in the basin.,"..
335 ","..
336 "Minetest distinguishes between liquid source and flowing liquid.,"..
337 ","..
338 "A liquid source block is always a full cube.,"..
339 "A flowing liquid block looks slightly different. Often\\, it is not a full cube\\, but has a more or less,"..
340 "triangular shape. Also\\, flowing liquids usually have an unique \"flowing\" animation\\, but this may,"..
341 "not be the case for all liuqids.,"..
342 ","..
343 "Up in the basin\\, you see four rows of liquid sources\\, followed by one row of flowing,"..
344 "liquids\\, followed by the waterfall itself. The waterfall itself is solely made of flowing liquids.,"..
345 ","..
346 "Liquid sources generate flowing liquids around them. Liquid sources can also exist on their own.,"..
347 "Flowing liquids are not able to exist on their own. They have to originate from a liquid source.,"..
348 "If the liquid source is gone\\, or the way to one is blocked\\, the flowing liquid will slowly dry,"..
349 "out.,"..
350 ","..
351 "To the left of this sign is a special block. When used\\, it will block the liquid flow.,"..
352 "Use that block\\, being close enough and looking at it\\, and watch the waterfall dry out.,"..
353 ","..
354 " Use something: \\[Right mouse button\\]"
356 tutorial.texts.viscosity = ""..
357 "Minetest mods can introduce various liquids which differ in their properties.,"..
358 "Probably the most important property is their viscosity. Here you have some,"..
359 "pools which differ in their viscosity. Feel free to try them out."
361 tutorial.texts.pointing1 = ""..
362 "An important general concept in Minetest is pointing. As mentioned earlier\\,,"..
363 "there is a crosshair in the center of the screen.,"..
365 "You can point several things in Minetest:,"..
366 ","..
367 "- Blocks,"..
368 "- Dropped items,"..
369 "- Other players,"..
370 "- Many other things,"..
371 ","..
372 "You can only point one thing at once\\, or nothing at all. You can tell when,"..
373 "you point something if it is surrounded by a thin cuboid wireframe.,"..
374 ","..
375 "To point something\\, three conditions have to be met:,"..
376 "1. The thing in question must be pointable at all,"..
377 "2. Your crosshair must be exactly over the thing in question,"..
378 "3. You must be close enough to the thing,"..
379 ","..
380 "When a thing is pointed\\, you can do different stuff with it\\; e.g. collecting it\\,,"..
381 "punching it\\, building to it\\, etc. We come to all that later.,"..
382 ","..
383 "Now collect that apple from the small tree in front of this sign\\, and the gold bar.,"..
384 "To do that\\, you must point it and click with the left mouse button."
387 tutorial.texts.pointing2 = ""..
388 "The distance you need to point to things solely depends on the tool you carry.,"..
389 "Most tools share a default value but some tools may have a longer or shorter distance.,"..
390 ","..
391 "At the moment\\, your only \"tool\" is the hand. It was good enough to collect the apple,"..
392 "from the small tree.,"..
393 ","..
394 "Above this sign hang some apples\\, but you cannot reach them by normal means. At the,"..
395 "wall in front of this sign lies a special example tool which you can use to retrieve the apple,"..
396 "from afar.,"..
397 ","..
398 "To take the tool\\, point on it and click the left mouse button. Then select it with the,"..
399 "mouse wheel or the number keys. You will learn more about tools in a different section."
401 tutorial.texts.health = ""..
402 "Unless you have damage disabled\\, all players start with 20 hit points (HP)\\, represented,"..
403 "by ten hearts in the heads-up display. One HP is represented by half a heart in this,"..
404 "tutorial\\, but the actual representation can vary from subgame to subgame.,"..
405 ","..
406 "You can take damage for the following reasons (including\\, but not limited to):,"..
407 "- Falling too deep,"..
408 "- Standing in a block which hurts you,"..
409 "- Attacks from other players,"..
410 "- Staying too long in a liquid,"..
411 ","..
412 "In this tutorial\\, you can regain health by eating a comestible. This is only an example\\,,"..
413 "mods and subgames may come with other mechanisms to heal you.,"..
414 ","..
415 "When you lose all your hit points\\, you die. Death is normally not really that bad in Minetest.,"..
416 "When you die\\, you will usually lose all your possessions. You are able to put yourself,"..
417 "into the world immediately again. This is called \"respawning\". Normally you appear at a,"..
418 "more or less random location.,"..
419 "In the tutorial you can die\\, too\\, but don't worry about that. You will,"..
420 "respawn at a special location you can't normally reach and keep all your posessions.,"..
421 "Subgames may introduce special events on a player's death."
423 tutorial.texts.death = ""..
424 "Oops! So it seems you just have died. Don't worry\\, you don't have lost any of your,"..
425 "possessions and you have been revived. You are still in Tutorial World at a different,"..
426 "location."..
427 ","..
428 "You have arrived at the so-called respawn location of Tutorial World. You will,"..
429 "always appear here after you died. This is called \"respawning\". In most worlds\\,,"..
430 "however\\, you will respawn in a slightly randomized location.,"..
431 ","..
432 "The tutorial uses a so-called fixed spawn point\\, so you respawn always at the same,"..
433 "spot. This is unusual for singleplayer worlds\\, but in online play some servers,"..
434 "use fixed spawn points\\, too.,"..
435 ","..
436 "Under normal conditions you would have lost all or a part of your possessions or some,"..
437 "other bad thing would have happened to you. But not here\\, this is a tutorial.,"..
438 ","..
439 "To continue\\, just drop out at the end of that gangway. The drop is safe."
444 tutorial.texts.items = ""..
445 "Throughout your journey\\, you will probably collect many items. Once you collected,"..
446 "them\\, blocks are considered to be items\\, too.,"..
447 ","..
448 "Items can be stored in your inventory and selected with the hotbar (see the other signs).,"..
449 "You can wield any items\\; you can even punch with almost any item to hurt enemies.,"..
450 "Usually\\, you will deal a minimal default damage with most items. Even if you do not hold,"..
451 "an item at all.,"..
452 "If you don\\'t want to have an item anymore\\, you can always throw it away. Likewise\\,,"..
453 "you can collect items which lie around by pointing and leftclicking them.,"..
454 ","..
455 " Collect item: \\[Left mouse button\\],"..
456 " Drop carried item stack: \\[Q\\],"..
457 " Drop single item from carried item stack: \\[Shift\\] + \\[Q\\],"..
458 ","..
459 "On the ledge at the right to this sign lies an item stack of 50 rocks so you have some items\\,,"..
460 "to test out the inventory."
462 tutorial.texts.tools = ""..
463 "A tool is a special kind of item.,"..
464 "Tools can be used for many things\\, such as:,"..
465 "- Breaking blocks,"..
466 "- Collecting liquids,"..
467 "- Rotating blocks,"..
468 "- Many others!,"..
469 "The number of tools which are possible in Minetest are innumberable and are,"..
470 "too many to cover in this tutorial.,"..
471 "But at least we will look at a very common and important tool type: mining tools\\,."..
472 "We will come to that in the mining section.,"..
473 ","..
474 "Many tools wear off and get destroyed after you used them for a while. In an,"..
475 "inventory the tool's \"health\" is indicated by a colored bar."..
476 ","..
477 "Tools may be able to be repaired\\, see the sign about repairing."
479 tutorial.texts.inventory = ""..
480 "The inventory menu usually contains the player inventory. This allows you,"..
481 "to carry along items throughout the world.,"..
482 ","..
483 "Every inventory is made out of slots where you can store items in. You can store one,"..
484 "entire stack of items per slot\\, the only condition is that the items are of the same,"..
485 "type. In this tutorial all items except for tools stack up to 99 items\\, but this number,"..
486 "can vary in actual subgames.,"..
487 ","..
488 "Here are the controls which explain how to move around the items within the inventory:,"..
489 ","..
490 "In the game:,"..
491 " Open inventory menu: \\[I\\]"..
492 ","..
493 "When the inventory is opened and you don't hold any items:,"..
494 " Take item stack: \\[Left mouse button\\],"..
495 " Take 10 items from item stack: \\[Middle mouse button\\],"..
496 " Take half item stack: \\[Right mouse button\\],"..
497 ","..
498 "When you took an item stack in the inventory:,"..
499 " Put item stack: \\[Left mouse button\\],"..
500 " Put 10 items from item stack: \\[Middle mouse button\\],"..
501 " Put single item from item stack: \\[Right mouse button\\],"..
502 ","..
503 "You can also drop an item stack by holding it in the inventory\\, then clicking anywhere,"..
504 "outside of the window."
506 tutorial.texts.chest = ""..
507 "This is a chest. You can view its contents by right-clicking it. In the menu you will see,"..
508 "two inventories\\, on the upper part the chest inventory and on the lower part the player,"..
509 "inventory. Exchanging items works exactly the same as in the inventory menu."
512 tutorial.texts.build = ""..
513 "Another important task in Minetest is building blocks.,"..
514 "\"Building\" here refers to the task of placing one block in your possession onto,"..
515 "another block in the world.,"..
516 "Unlike mining\\, building a block happens instantanous. To build\\, select a block in your,"..
517 "hotbar\\, point to any block in the world and press the right mouse button.,"..
518 "Your block will be immediately placed on the pointed side.,"..
519 "It is important that the block you want to build to is pointable. This means you cannot build,"..
520 "next to or on liquids by normal means.,"..
521 ","..
522 " Build on ordinary block: \\[Right mouse button\\],"..
523 ","..
524 "Try to get up to that little hole by using the wood blocks in the chest. There is another,"..
525 "gold ingot waiting for you."
527 tutorial.texts.mine = ""..
528 "\"Mining\" is a method to remove a single block with a mining tool. It is a very important,"..
529 "task in Minetest which you will use often.,"..
530 ","..
531 "(It is recommended that you go to the crafting and items house first. It is right in front of,"..
532 "this sign.),"..
533 ","..
534 "To be able to mine a block\\, you need,"..
535 ","..
536 "1. to have minable block\\, after all\\,,"..
537 "2. to point on the block and,"..
538 "3. to carry an appropriate tool.,"..
539 ","..
540 " Mine: \\[Left mouse button\\],"..
541 ","..
542 "When you are ready\\, hold the left mouse button while pointing the block. Depending on,"..
543 "the block type and the tool properties\\, this can take some time. Some tools are fast with,"..
544 "some particular block types\\, some other tools may be slower to mine other block types.,"..
545 "If you do not carry an appropriate tool\\, you are not able to mine the block at all.,"..
546 "You can tell that you are actually mining when you see cracks or some other animation,"..
547 "on the block in question.,"..
548 ","..
549 "When done mining\\, blocks will often add one or more items to your inventory. This is called,"..
550 "the \"drop\" of a block and depends on the block type. Now try to mine those large cubes in,"..
551 "this area\\, using different tools. Note that all blocks here are just examples to show you,"..
552 "different kinds of drops."
554 tutorial.texts.mine_cobble = ""..
555 "This is cobblestone. You can mine it with a pickaxe.,"..
556 "This cobblestone will always drop itself\\, that means\\, cobblestone. Dropping itself is the,"..
557 "usual dropping behaviour of a block\\, throughout many subgames."
559 tutorial.texts.mine_wood = ""..
560 "These are wooden planks. In the tutorial\\, you can only mine those blocks with an axe.,"..
561 "Wooden planks drop themselves.,"..
562 ","..
563 "In Minetest\\, we use the term \"mining\" in a general sense\\, regardless of the material."
565 tutorial.texts.mine_conglomerate = ""..
566 "This is a cube of conglomerate. You need a pickaxe to mine it.,"..
567 "Conglomerate drops something based on probability. Conglomerate randomly drops between 1,"..
568 "and 5 rocks\\, when mined."
570 tutorial.texts.mine_glass = ""..
571 "This is some weak glass. You can break it with your bare hands. Or you can use your pickaxe\\,,"..
572 "which is faster. Note that it looks slightly different than the other glass in this world.,"..
573 "These glass blocks don't drop anything."
575 tutorial.texts.mine_stone = ""..
576 "This is stone. You need a pickaxe to mine it. When mined\\, stone will drop cobblestone."
578 tutorial.texts.mine_immortal = ""..
579 "There can always be some blocks which are not minable by any tool. In our tutorial\\, all,"..
580 "those castle walls can't me mined\\, for example."
582 tutorial.texts.craft1 = ""..
583 "Crafting is the task of taking several items and combining them to form a new item.,"..
584 "Crafting is another important task in Minetest.,"..
585 ","..
586 "To craft something\\, you need a few items and a so-called crafting grid.,"..
587 ","..
588 "In this tutorial\\, you have a grid of size 3 times 3 in your inventory.,"..
589 "Let's get right into crafting:,"..
590 ","..
591 "1. Take 3 sheets of paper from the chest next to this sign.,"..
592 "2. Open the inventory menu with \\[I\\].,"..
593 "3. Place the paper in the crafting grid so that they form a 1×3 vertical line.,"..
594 "4. A book should appear in the output slot. Click on it to take it\\,,"..
595 " then put it in your player inventory.,"..
596 ","..
597 "This process consumes the paper.,"..
598 "When you have the book in your inventory\\, go on with the next sign."
600 tutorial.texts.craft2 = ""..
601 "To craft the book you have used a so-called crafting recipe. You must know the crafting,"..
602 "recipes as well so you can craft.,"..
603 ","..
604 "The crafting recipe you used in particular is a so-called shaped recipe. This means the,"..
605 "pattern you place in the crafting grid matters\\, but you can move the entire pattern,"..
606 "freely.,"..
607 ","..
608 "There is another kind of crafting recipe: Shapeless.,"..
609 "Shapeless recipes only care about which items you place in the crafting grid\\, but not in,"..
610 "which pattern. In the next chest you find some wheat. Let's make dough from it! For this,"..
611 "you have to place at least 1 wheat in 4 different slots\\, but the other slots must be empty.,"..
612 "What is special about this recipe is that you can place them anywhere in the grid.,"..
613 ","..
614 "When you got your dough\\, go on with the next sign."
616 tutorial.texts.craft3 = ""..
617 "Do you got your dough? Good.,"..
618 ","..
619 "You may have noticed that crafting always consumes one item from each occupied slot,"..
620 "of the crafting grid. This is true for all crafting recipes.,"..
621 "You can speed crafting up a bit when you click with the middle mouse button on the,"..
622 "item in the output slot. Doing so will attempt to do the same craft up to 10 times\\,,"..
623 "instead of just once.,"..
624 ","..
625 "Feel free to try it with the remaining wheat or just go on with the next sign."
627 tutorial.texts.craft4 = ""..
628 "Another important thing to know about crafting are so-called groups. Crafting recipes do,"..
629 "not always require you to use the exactly same items every time.,"..
630 "This tutorial has a special recipe for books. In the chest\\, you will find paper in 4,"..
631 "different colors. You can also make a book by placing 3 paper sheets of any color,"..
632 "in a vertical line.,"..
633 "The paper color does not matter here\\, you can use only white paper\\, only orange paper,"..
634 "or even mix it. What is important here are the occupied slots.,"..
635 "This is possible because all 4 types of (example) paper belong to the same group and,"..
636 "our book recipe accepts not only white paper\\, but any paper of that group.,"..
637 ","..
638 "Feel free to experiment a bit around with this."
640 tutorial.texts.smelt = ""..
641 "This is a furnace. Furnaces can be used to turn a smeltable item with help of a fuel,"..
642 "to a new item. Many items can be furnace fuels\\, but not all. A few items are smeltable.,"..
643 ","..
644 "In order to operate a furnace\\, you have to put the smeltable item into the 'Source' slot,"..
645 "and the fuel into the 'Fuel' slot.,"..
646 "As soon as the items have been placed\\, the furnace automatically starts to smelt the,"..
647 "items. The furnace becomes active and consumes an item in the fuel slot. The flame,"..
648 "goes on and will continue burning for a given time. The time depends on the fuel type.,"..
649 "Some fuels burn very short\\, and other burn longer. In the furnace menu\\, the burn time,"..
650 "is indicated by the flame symbol. As soon as the flame goes out\\, the furnace may,"..
651 "continue burning if there is still fuel and smeltable material in the furnace\\,,"..
652 "otherwise\\, the furnace becomes inactive again.,"..
653 "The smeltable material has to be exposed to the flame for a given time as well. This,"..
654 "time depends on the type of the material\\, too. Some material smelt faster than others.,"..
655 "You can see the smelting progress of a single item on the progress arrow. If one item,"..
656 "has been smelt\\, the result goes to one of the output slots\\, where you can take it.,"..
657 ","..
658 "In the left chest you find some fuels and in the right chest you find some materials to,"..
659 "smelt. Feel free to experiment with the furnace a bit. Smelt the gold lump to receive,"..
660 "this station's gold bar."..
661 ","..
662 "Again\\, this furnace is just an example\\; the exact operation may differ slightly from,"..
663 "subgame to subgame."
665 tutorial.texts.repair = ""..
666 "Some subgames may come with a special recipe which allows you to repair your tools.,"..
667 "In those\\, repairing works always the same way:,"..
668 "Place two more or less worn out tools of the same kind into the crafting crid and,"..
669 "take the result. The result is a new tool which is slightly repaired by a fixed percentage.,"..
670 ","..
671 "Of course\\, this tutorial comes with such a recipe. The chest next to this sign stores,"..
672 "some damaged tools which you may try to repair now."
675 tutorial.texts.use = ""..
676 "You will often meet some blocks you can use. Something special happens when you,"..
677 "right-click while pointing on them.,"..
678 "In fact\\, you already used such blocks: All the signs you read are \"usable\" blocks.,"..
679 ","..
680 "There is a strange device next to this sign. Use it and see what happens.,"..
681 ","..
682 " Use usable block: \\[Right mouse button\\]"
685 tutorial.texts.basic_end = ""..
686 "If you think you have enough of this tutorial\\, you can leave at any time. There are,"..
687 tostring(tutorial.gold).." gold ingots at the stations to be found\\, to help you keep track."..
688 ","..
689 "You can find the gold ingots at the following stations:,"..
690 "- Ladders,"..
691 "- Sneaking,"..
692 "- Swimming,"..
693 "- Diving,"..
694 "- Waterfall,"..
695 "- Viscosity,"..
696 "- Comestibles and Eating,"..
697 "- Pointing,"..
698 "- Crafting,"..
699 "- Smelting,"..
700 "- Mining,"..
701 "- Building,"..
702 "- Damage and Health,"..
703 ","..
704 "If you got "..tostring(tutorial.gold).." gold ingots (in total)\\, you probably know now everything,"..
705 "which can be learned from this tutorial. Collecting the gold ingots is optional and won't give you,"..
706 "anything special."..
707 ","..
708 "After you closed this dialog\\, you can press \\[Esc\\] to open the pause menu and return,"..
709 "to the main menu or quit Minetest.,"..
710 ","..
711 "In the next room there are some further signs with information\\, but it is entirely optional,"..
712 "and not related to gameplay."
714 tutorial.texts.fallout = ""..
715 "You somehow managed to fall from the castle or got otherwise below it!,"..
716 "How did you do that?,"..
717 ","..
718 "Anyways\\, I have teleported you back to the starting location. Whatever you did\\, be more,"..
719 "careful next time."
721 tutorial.texts.first_gold = ""..
722 "You have collected your first gold ingot. Those will help you to keep track in this tutorial.,"..
723 "There are "..tostring(tutorial.gold).." golden ingots in this tutorial.,"..
724 ","..
725 "There is a gold ingot at every important station. If you collected all ingots\\, you are,"..
726 "done with the tutorial\\, but collecting the gold ingots is not mandatory."
728 tutorial.texts.last_gold = ""..
729 "You have collected all the gold ingots in this tutorial.,"..
730 ","..
731 "This means you have now travelled to each station. If you read and understood everything\\,,"..
732 "you have learned everything which can be learned from this tutorial.,"..
733 ","..
734 "If this is the case\\, you are finished with this tutorial and can leave now. But feel,"..
735 "free to stay in this world to explore the area a bit further.,"..
736 ","..
737 "You may also want to visit the Good-Bye room\\, which has a few more informational,"..
738 "signs with supplemental information\\, but nothing of is is essential or gameplay-relevant.,"..
739 ","..
740 "If you want to stay\\, you leave later by pressing \\[Esc\\] to open the pause menu and then,"..
741 "return to the main menu or quit Minetest."
743 tutorial.texts.first_diamond = ""..
744 "Great\\, you have found and collected a hidden diamond! In Tutorial World\\, there are "..tostring(tutorial.diamonds).." hidden,"..
745 "diamonds. Can you find them all? The first diamond may have been easy to collect\\, but the,"..
746 "remaining "..tostring(tutorial.diamonds-1).." diamonds probably won't be that easy.,"..
747 ","..
748 "There won't be any special event or bonus\\, however\\, if you manage to collect all,"..
749 tostring(tutorial.diamonds).." diamonds\\, apart from feeling special\\, maybe. \\;-)"
751 tutorial.texts.last_diamond = ""..
752 "Congratulations!,"..
753 "You have collected all the diamonds of Tutorial World!,"..
754 ","..
755 "You can feel special now."
758 tutorial.texts.controls = ""..
759 "To recap\\, here is an overview over the most important default controls:,"..
760 ","..
761 " Move forwards: \\[W\\],"..
762 " Move left: \\[A\\],"..
763 " Move backwards: \\[S\\],"..
764 " Move right: \\[D\\],"..
765 " Jump: \\[Space\\],"..
766 " Sneak: \\[Shift\\],"..
767 " Move upwards (ladder/liquid): \\[Space\\],"..
768 " Move downwards (ladder/liquid): \\[Shift\\],"..
769 ","..
770 " Toggle camera mode: \\[F7\\],"..
771 ","..
772 " Select item in hotbar: \\[Mouse wheel\\],"..
773 " Select item in hotbar: \\[0\\] - \\[9\\],"..
774 " Inventory menu: \\[I\\],"..
775 ","..
776 " Collect pointed item: \\[Left mouse button\\],"..
777 " Drop item stack: \\[Q\\],"..
778 " Drop single item: \\[Shift\\] + \\[Q\\],"..
779 ","..
780 " Punch: \\[Left mouse button\\],"..
781 " Mine: \\[Left mouse button\\],"..
782 " Build/use: \\[Right mouse button\\],"..
783 " Build: \\[Shift\\] + \\[Right mouse button\\]"..
784 ","..
785 " Abort/open pause menu: \\[Esc\\],"..
786 ","..
787 "You can review a shorter version of the controls in the pause menu."
790 tutorial.texts.online = ""..
791 "You may want to check out these online resources related to Minetest:,"..
792 ","..
793 "Official homepage of Minetest: <http://minetest.net/>,"..
794 "The main place to find the most recent version of Minetest.,"..
795 ","..
796 "Community wiki: <http://wiki.minetest.net/>,"..
797 "A community-based documentation website for Minetest. Anyone with an account can edit,"..
798 "it! It also features a documentation of the default game\\, which was NOT covered by,"..
799 "this tutorial.,"..
800 ","..
801 "Webforums: <http://forums.minetest.net/>,"..
802 "A web-based discussion platform where you can discuss everything related to Minetest.,"..
803 "This is also a place where player-made mods and subgames are published and,"..
804 "discussed. The discussions are mainly in English\\, but there is also space for,"..
805 "discussion in other languages.,"..
806 ","..
807 "Chat: <irc://irc.freenode.net#minetest>,"..
808 "A generic Internet Relay Chat channel for everything related to Minetest where people can,"..
809 "meet to discuss in real-time.,"..
810 "If you do not understand IRC\\, see the Community Wiki for help."
813 tutorial.register_infosign("intro", "Introduction", tutorial.texts.intro)
814 tutorial.register_infosign("minetest", "Minetest", tutorial.texts.minetest)
815 tutorial.register_infosign("cam", "Player Camera", tutorial.texts.cam)
816 tutorial.register_infosign("runover", "Small Abysses", tutorial.texts.runover)
817 tutorial.register_infosign("jumpup", "Jumping (1)", tutorial.texts.jumpup)
818 tutorial.register_infosign("jumpover", "Jumping (2)", tutorial.texts.jumpover)
819 tutorial.register_infosign("sneak", "Sneaking", tutorial.texts.sneak)
820 tutorial.register_infosign("orientation", "Information about the following tutorial sections", tutorial.texts.orientation)
821 tutorial.register_infosign("hotbar", "Hotbar", tutorial.texts.hotbar)
822 tutorial.register_infosign("eat", "Comestibles and Eating", tutorial.texts.eat)
823 tutorial.register_infosign("chest", "Chests", tutorial.texts.chest)
824 tutorial.register_infosign("damageblock", "Blocks Which Hurt You", tutorial.texts.damageblock)
825 tutorial.register_infosign("ladder", "Climbing Ladders", tutorial.texts.ladder)
826 tutorial.register_infosign("swim", "Swimming", tutorial.texts.swim)
827 tutorial.register_infosign("dive", "Diving", tutorial.texts.dive)
828 tutorial.register_infosign("waterfall", "Swimming up a Waterfall", tutorial.texts.waterfall)
829 tutorial.register_infosign("viscosity", "Viscosity", tutorial.texts.viscosity)
830 tutorial.register_infosign("liquidtypes", "Liquid sources and flowing liquids", tutorial.texts.liquidtypes)
831 tutorial.register_infosign("pointing1", "Pointing (1)", tutorial.texts.pointing1)
832 tutorial.register_infosign("pointing2", "Pointing (2)", tutorial.texts.pointing2)
833 tutorial.register_infosign("health", "Health and Damage", tutorial.texts.health)
834 tutorial.register_infosign("death", "Death and Respawning", tutorial.texts.death)
835 tutorial.register_infosign("items", "Items", tutorial.texts.items)
836 tutorial.register_infosign("tools", "Tools", tutorial.texts.tools)
837 tutorial.register_infosign("inventory", "Using the Inventory", tutorial.texts.inventory)
838 tutorial.register_infosign("chest", "Comment About Chests", tutorial.texts.chest)
839 tutorial.register_infosign("build", "Building Some Blocks", tutorial.texts.build)
840 tutorial.register_infosign("mine", "Mining blocks", tutorial.texts.mine)
841 tutorial.register_infosign("mine_cobble", "Mining example: Cobblestone", tutorial.texts.mine_cobble)
842 tutorial.register_infosign("mine_stone", "Mining example: Stone", tutorial.texts.mine_stone)
843 tutorial.register_infosign("mine_conglomerate", "Mining example: Conglomerate", tutorial.texts.mine_conglomerate)
844 tutorial.register_infosign("mine_wood", "Mining example: Wooden Planks", tutorial.texts.mine_wood)
845 tutorial.register_infosign("mine_glass", "Mining example: Weak glass", tutorial.texts.mine_glass)
846 tutorial.register_infosign("mine_immortal", "Unminable blocks", tutorial.texts.mine_immortal)
847 tutorial.register_infosign("blocks", "Special blocks", tutorial.texts.blocks)
848 tutorial.register_infosign("disable_jump", "No-jumping blocks", tutorial.texts.disable_jump)
849 tutorial.register_infosign("falling_node", "Falling blocks", tutorial.texts.falling_node)
850 tutorial.register_infosign("attached_node", "Attached blocks", tutorial.texts.attached_node)
851 tutorial.register_infosign("use", "Using blocks", tutorial.texts.use)
852 tutorial.register_infosign("craft1", "Crafting Basics", tutorial.texts.craft1)
853 tutorial.register_infosign("craft2", "Crafting using Shapeless Recipes", tutorial.texts.craft2)
854 tutorial.register_infosign("craft3", "Crafting Faster", tutorial.texts.craft3)
855 tutorial.register_infosign("craft4", "Crafting Groups", tutorial.texts.craft4)
856 tutorial.register_infosign("smelt", "Furnace Operation Instructions", tutorial.texts.smelt)
857 tutorial.register_infosign("repair", "Repairing Tools", tutorial.texts.repair)
858 tutorial.register_infosign("basic_end", "End of the Basic Tutorial", tutorial.texts.basic_end)
859 tutorial.register_infosign("controls", "Controls Overview", tutorial.texts.controls)
860 tutorial.register_infosign("online", "Online Resources", tutorial.texts.online)
861 tutorial.register_infosign("subgame", "Subgames", tutorial.texts.subgame)
863 minetest.register_node("tutorial:wall", {
864 description = "Reinforced Wall",
865 tiles = {"default_stone_brick.png"},
866 is_ground_content = true,
867 groups = {immortal=1},
868 sounds = default.node_sound_stone_defaults(),
871 minetest.register_node("tutorial:reinforced_glass", {
872 description = "Reinforced Glass",
873 drawtype = "glasslike",
874 tiles = {"tutorial_reinforced_glass.png"},
875 inventory_image = minetest.inventorycube("tutorial_reinforced_glass.png"),
876 paramtype = "light",
877 sunlight_propagates = true,
878 groups = { immortal=1 },
879 sounds = default.node_sound_glass_defaults(),
882 minetest.register_node("tutorial:weak_glass", {
883 description = "Weak Glass",
884 drawtype = "glasslike",
885 tiles = {"tutorial_weak_glass.png"},
886 inventory_image = minetest.inventorycube("tutorial_weak_glass.png"),
887 paramtype = "light",
888 sunlight_propagates = true,
889 groups = { cracky=3, oddly_breakable_by_hand=1 },
890 drop = "",
891 sounds = default.node_sound_glass_defaults(),
895 minetest.register_tool("tutorial:snatcher", {
896 description = "Apple Snatcher",
897 inventory_image = "tutorial_snatcher.png",
898 wield_image = "tutorial_snatcher.png",
899 wield_scale = { x = 1, y = 1, z = 1 },
900 range = 10,
901 tool_capabilities = {},
904 --[[ A special switch which, when flipped, exchanges day for night and vice versa. ]]
905 minetest.register_node("tutorial:day", {
906 description = "Day/Night Switch (Day)",
907 tiles = { "tutorial_day.png" },
908 groups = {immortal=1},
909 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
910 minetest.set_timeofday(0)
911 minetest.set_node(pos, {name="tutorial:night"})
914 minetest.register_node("tutorial:night", {
915 description = "Day/Night Switch (Night)",
916 tiles = { "tutorial_night.png" },
917 groups = {immortal=1},
918 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
919 minetest.set_timeofday(0.5)
920 minetest.set_node(pos, {name="tutorial:day"})
924 --[[ A special switch which "activates" and "deactivates" the waterfall in Tutorial World.
925 It only works on a prepared map! ]]
926 minetest.register_node("tutorial:waterfall_on", {
927 description = "Waterfall Switch (on)",
928 tiles = { "tutorial_waterfall_on.png" },
929 groups = {immortal=1},
930 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
931 local wpos = { y = 5, z = 86 }
932 for x=33,46 do
933 wpos.x = x
934 minetest.set_node(wpos, {name="tutorial:wall"})
936 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_off"})
937 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_off"})
940 minetest.register_node("tutorial:waterfall_off", {
941 description = "Waterfall Switch (off)",
942 tiles = { "tutorial_waterfall_off.png" },
943 groups = {immortal=1},
944 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
945 local wpos = { y = 5, z = 86 }
946 for x=33,46 do
947 wpos.x = x
948 minetest.remove_node(wpos)
950 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_on"})
951 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_on"})
955 --[[ This function shows a simple dialog window with scrollable text
956 name: name of the player to show the formspec to
957 caption: Caption of the dialog window (not escaped)
958 text: The text to be shown. Must be escaped manually for formspec, an unescaped
959 comma generates a line break.
961 function tutorial.show_default_dialog(name, caption, text)
962 local formspec = "size[12,6]"..
963 "label[-0.15,-0.4;"..minetest.formspec_escape(caption).."]"..
964 "tablecolumns[text]"..
965 "tableoptions[background=#000000;highlight=#000000;border=false]"..
966 "table[0,0.25;12,5.2;text_table;"..
967 text..
968 "]"..
969 "button_exit[4.5,5.5;3,1;close;Close]"
970 minetest.show_formspec(name, "tutorial_dialog", formspec)
973 minetest.register_on_joinplayer(function(player)
974 local formspec = nil
975 if(minetest.is_singleplayer() == false) then
976 formspec = "size[12,6]"..
977 "label[-0.15,-0.4;Warning: Not playing in singleplayer mode]"..
978 "tablecolumns[text]"..
979 "tableoptions[background=#000000;highlight=#000000;border=false]"..
980 "table[0,0.25;12,5.2;creative_text;"..
981 tutorial.texts.notsingleplayer..
982 "]"..
983 "button_exit[2.5,5.5;3,1;close;Continue anyways]"..
984 "button_exit[6.5,5.5;3,1;leave;Leave tutorial]"
985 elseif(minetest.setting_getbool("creative_mode")) then
986 formspec = "size[12,6]"..
987 "label[-0.15,-0.4;Warning: Creative mode is active]"..
988 "tablecolumns[text]"..
989 "tableoptions[background=#000000;highlight=#000000;border=false]"..
990 "table[0,0.25;12,5.2;creative_text;"..
991 tutorial.texts.creative..
992 "]"..
993 "button_exit[2.5,5.5;3,1;close;Continue anyways]"..
994 "button_exit[6.5,5.5;3,1;leave;Leave tutorial]"
996 else
997 if(tutorial.state.first_join==true) then
998 formspec = "size[12,6]"..
999 "label[-0.15,-0.4;Introduction]"..
1000 "tablecolumns[text]"..
1001 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1002 "table[0,0.25;12,5.2;intro_text;"..
1003 tutorial.texts.intro..
1004 "]"..
1005 "button_exit[4.5,5.5;3,1;close;Close]"
1007 tutorial.state.first_join = false
1008 tutorial.save_state()
1010 if(formspec~=nil) then
1011 minetest.show_formspec(player:get_player_name(), "intro", formspec)
1016 minetest.register_on_player_receive_fields(function(player, formname, fields)
1017 if(fields.leave) then
1018 minetest.kick_player(player:get_player_name(), "You voluntarily have exited the tutorial.")
1020 if(fields.gotostart) then
1021 tutorial.back_to_start(player)
1023 if(fields.gotoend) then
1024 tutorial.go_to_end(player)
1026 end)
1028 tutorial.steptimer = 0
1029 minetest.register_globalstep(function(dtime)
1030 tutorial.steptimer = tutorial.steptimer + dtime
1031 local players = minetest.get_connected_players()
1032 if(tutorial.steptimer > 2) then
1033 for p=1,#players do
1034 local player = players[p]
1035 local name = player:get_player_name()
1036 if(player:getpos().y < -12 and (not minetest.setting_getbool("creative_mode"))) then
1037 -- teleport players back to the start when they fell away
1038 tutorial.back_to_start(player)
1039 tutorial.show_default_dialog(name, "You fell from the castle!", tutorial.texts.fallout)
1041 else
1042 local inv = player:get_inventory()
1043 local state_changed = false
1045 if(tutorial.state.first_gold ~= true) then
1046 local gold_stack = ItemStack("default:gold_ingot 1")
1047 if(inv:contains_item("main", gold_stack)) then
1048 tutorial.show_default_dialog(
1049 name,
1050 "Gold ingot",
1051 tutorial.texts.first_gold
1053 tutorial.state.first_gold = true
1054 state_changed = true
1057 if(tutorial.state.last_gold ~= true) then
1058 local gold_stack = ItemStack("default:gold_ingot "..tostring(tutorial.gold))
1059 if(inv:contains_item("main", gold_stack)) then
1060 local formspec = "size[12,6]"..
1061 "label[-0.15,-0.4;You've finished the tutorial!]"..
1062 "tablecolumns[text]"..
1063 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1064 "table[0,0.25;12,5.2;creative_text;"..
1065 tutorial.texts.last_gold..
1066 "]"..
1067 "button_exit[0.5,5.5;3,1;close;Continue]"..
1068 "button_exit[4.5,5.5;3,1;leave;Leave tutorial]"..
1069 "button_exit[8.5,5.5;3,1;gotoend;Go to Good-Bye room]"
1071 minetest.show_formspec(name, "tutorial_last_gold", formspec)
1073 tutorial.state.last_gold = true
1074 state_changed = true
1078 if(tutorial.state.first_diamond ~= true) then
1079 local diamond_stack = ItemStack("default:diamond 1")
1080 if(inv:contains_item("main", diamond_stack)) then
1081 tutorial.show_default_dialog(
1082 name,
1083 "You found a hidden diamond!",
1084 tutorial.texts.first_diamond
1086 tutorial.state.first_diamond = true
1087 state_changed = true
1090 if(tutorial.state.last_diamond ~= true) then
1091 local diamond_stack = ItemStack("default:diamond "..tostring(tutorial.diamonds))
1092 if(inv:contains_item("main", diamond_stack)) then
1093 tutorial.show_default_dialog(
1094 name,
1095 "You have collected all hidden diamonds!",
1096 tutorial.texts.last_diamond
1098 tutorial.state.last_diamond = true
1099 state_changed = true
1103 if(state_changed) then
1104 tutorial.save_state()
1108 tutorial.steptimer = 0
1110 end)
1112 function tutorial.back_to_start(player)
1113 player:setpos({x=42,y=0.5,z=28})
1116 function tutorial.go_to_end(player)
1117 player:setpos({x=23,y=0.5,z=74})
1120 --[[
1121 FIXME: This does not work in 0.4.10 thanks to a bug. Uncomment this as soon as
1122 set_physics_override gets fixed
1124 function tutorial.disable_sneak_glitch(player)
1125 player:set_physics_override({sneak_glitch=false, sneak=false})
1128 minetest.register_on_newplayer(tutorial.disable_sneak_glitch)
1129 minetest.register_on_joinplayer(tutorial.disable_sneak_glitch)
1130 minetest.register_on_respawnplayer(tutorial.disable_sneak_glitch)