Remove comments ...
[minetest_tutorial_subgame.git] / mods / tutorial / init.lua
blob0d060fcb3fd840c495574a78e18a9640871383cc
1 tutorial = {}
3 -- intllib support
4 local S
5 if (minetest.get_modpath("intllib")) then
6 dofile(minetest.get_modpath("intllib").."/intllib.lua")
7 S = intllib.Getter(minetest.get_current_modname())
8 else
9 S = function ( s ) return s end
10 end
12 -- Saves tutorial state into file
13 function tutorial.save_state()
14 local str = minetest.serialize(tutorial.state)
15 local filepath = minetest.get_worldpath().."/tutorialdata.mt"
16 local file = io.open(filepath, "w")
17 if(file) then
18 file:write(str)
19 minetest.log("action", "[tutorial] Tutorial state has been written into "..filepath..".")
20 else
21 minetest.log("error", "[tutorial] An attempt to save the tutorial state into "..filepath.." failed.")
22 end
23 end
26 -- load tutorial state from file
28 local filepath = minetest.get_worldpath().."/tutorialdata.mt"
29 local file = io.open(filepath, "r")
30 local read = false
31 if file then
32 local string = file:read()
33 io.close(file)
34 if(string ~= nil) then
35 tutorial.state = minetest.deserialize(string)
36 minetest.log("action", "[tutorial] Tutorial state has been read from "..filepath..".")
37 read = true
38 end
39 end
40 if(read==false) then
41 tutorial.state = {}
43 -- Is this the first time the player joins this tutorial?
44 tutorial.state.first_join = true
45 -- These variables store wheather a message for those events has been shown yet.
46 tutorial.state.first_gold = false
47 tutorial.state.last_gold = false
48 tutorial.state.first_diamond = false
49 tutorial.state.last_diamond = false
50 end
52 function tutorial.convert_newlines(str)
53 if(type(str)~="string") then
54 return "ERROR: No string found!"
55 end
57 local function convert(s)
58 return s:gsub("\n", function(slash, what)
59 return ","
60 end)
61 end
63 return convert(str)
64 end
66 function tutorial.register_infosign(itemstringpart, caption, fulltext)
67 minetest.register_node("tutorial:sign_"..itemstringpart, {
68 description = string.format(S("tutorial sign '%s'"), S(caption)),
69 drawtype = "signlike",
70 tiles = {"default_sign_wall.png"},
71 inventory_image = "default_sign_wall.png",
72 wield_image = "default_sign_wall.png",
73 paramtype = "light",
74 paramtype2 = "wallmounted",
75 sunlight_propagates = true,
76 is_ground_content = false,
77 walkable = false,
78 selection_box = { type = "wallmounted" },
79 groups = {immortal=1,attached_node=1,tutorial_sign=1},
80 legacy_wallmounted = true,
81 sounds = default.node_sound_defaults(),
82 on_construct = function(pos)
83 local meta = minetest.get_meta(pos)
84 local formspec = ""..
85 "size[12,6]"..
86 "label[-0.15,-0.4;"..minetest.formspec_escape(S(caption)).."]"..
87 "tablecolumns[text]"..
88 "tableoptions[background=#000000;highlight=#000000;border=false]"..
89 "table[0,0.25;12,5.2;infosign_text;"..
90 tutorial.convert_newlines(minetest.formspec_escape(S(fulltext)))..
91 "]"..
92 "button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
93 meta:set_string("formspec", formspec)
94 meta:set_string("infotext", string.format(S("%s (Right-click to read)"), S(caption)))
95 meta:set_string("id", itemstringpart)
96 meta:set_string("caption", caption)
97 end
99 end
101 minetest.register_abm( {
102 nodenames = {"group:tutorial_sign"},
103 interval = 1,
104 chance = 1,
105 action = function(pos, node, active_object_count, active_object_count_wider)
106 local meta = minetest.get_meta(pos)
107 local id = meta:get_string("id")
108 local caption = meta:get_string("caption")
109 local formspec = ""..
110 "size[12,6]"..
111 "label[-0.15,-0.4;"..minetest.formspec_escape(S(caption)).."]"..
112 "tablecolumns[text]"..
113 "tableoptions[background=#000000;highlight=#000000;border=false]"..
114 "table[0,0.25;12,5.2;infosign_text;"..
115 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts[id])))..
116 "]"..
117 "button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
118 meta:set_string("formspec", formspec)
119 meta:set_string("infotext", string.format(S("%s (Right-click to read)"), S(caption)))
121 end }
125 -- Number of gold ingots/lumps
126 tutorial.gold = 13
128 -- Number of hidden diamonds
129 tutorial.diamonds = 12
133 tutorial.texts = {}
134 tutorial.texts.intro =
135 [[Welcome! This tutorial will teach you the most crucial basics of Minetest.
136 This tutorial assumes that you have not changed the default keybindings yet.
138 Let's start for the most important keybindings right now:
140 Look around: Move the mouse
141 Walk forwards: [W]
142 Strafe left: [A]
143 Walk backwards: [S]
144 Strafe right: [D]
145 Action: [Right mouse button]
146 Pause menu (you can exit the game here): [Esc]
148 You will find signs with more introductionary texts throughout this tutorial.
149 The "action" key has many uses. For now, let's just say you need it to read
150 the signs. Look at one and right-click it to read it.
152 To look at a sign, make sure you are close enough to it and the crosshair in the
153 center of the screen points directly on the sign.
155 You can exit the tutorial at any time, the world will be automatically saved.
157 Now feel free to walk around a bit and read the other signs to learn more.]]
159 tutorial.texts.minetest =
160 [[Minetest itself is not a game, it is a game engine.
161 To be able to actually play it, you need something called a "Minetest game",
162 sometimes also called "subgame" or just "game". In this tutorial, we use the term,
163 "subgame".
165 Don't worry, Minetest comes pre-installed with a rather simple default subgame, oddly,
166 also called "Minetest"
168 This tutorial teaches you the basics of Minetest (the engine), things which are true for
169 all subgames. This tutorial does not teach you how to play a particular subgame, not
170 even the default one.
172 Minetest as well as the default subgame are unfinished at the moment, so please forgive
173 us when not everything works out perfectly.]]
175 tutorial.texts.subgame =
176 [[Now since you probably now the basics, you may want to actually play or build something.
177 Minetest comes bundled with a default subgame, which you may try out now.
178 Sadly, there is currently no tutorial for the default subgame.
179 You may want to read the "Getting Started" section of the Community Wiki,
180 which is more specific about the default subgame.
181 Said document can be found at:
183 <http://wiki.minetest.net/Getting_Started>
185 Alternatively, you may check out one of the subgames which are shared on the Minetest forums.]]
188 tutorial.texts.creative =
189 [[The creative mode is turned on. If you are here to learn how to play Minetest,
190 you should probably leave now, turn creative mode off and restart the
191 tutorial.
193 Roughly spoken, creative mode is for messing around with the game without
194 the normal gameplay restraints.
196 You can leave now by pressing "Leave tutorial", or later, by pressing [Esc].]]
198 tutorial.texts.notsingleplayer =
199 [[You are now playing the tutorial in multiplayer mode.
200 But this tutorial is optimized for the singleplayer mode.
201 This tutorial does not work properly with more than 1 player.
203 Unless you are sure no other players will join, you should
204 leave now and start the tutorial in singleplayer mode.]]
206 tutorial.texts.cam =
207 [=[Minetest has 3 different camera modes which determine the way you see the world.
208 The three modes are:
210 - First-person view (default)
211 - Third-person view from behind
212 - Third-person view from the front
214 You can change the camera mode by pressing [F7] (but you have to close this
215 window first).
217 Switch camera mode: [F7]]=]
219 tutorial.texts.blocks =
220 [[The world of Minetest is made entirely out of blocks, or voxels, to be precise.
221 Blocks can be added or removed with the correct tools.
223 In this section, we'll show you a few special but common blocks which behave in unexpected,
224 ways.,
226 Of course, subgames can come up with more special weird blocks.]]
228 tutorial.texts.falling_node =
229 [[Some blocks need to rest on top of another block, otherwise, they fall down.
230 Try it and mine the block below the uppermost block.]]
232 tutorial.texts.attached_node =
233 [[Some blocks have to be attached to another block, otherwise, they drop as an item
234 as if you would have mined it.
236 Attached here is a picture frame. You can't collect or mine it directly, but if you mine
237 the block it is attached to, it will drop as an item which you can collect.]]
239 tutorial.texts.disable_jump =
240 [[These nasty blocks on the floor prevent you from jumping when you stand on them.]]
242 tutorial.texts.runover =
243 [[This abyss behind this sign is so small that you can even walk over it,
244 as long as you don't stop midway. But you can jump over it anyways, just to be,
245 safe.]]
247 tutorial.texts.jumpup =
248 [[You can't reach this upper block by walking. But luckily, you are able to jump.
249 For our purposes, you can jump just high enough to reach one block above you.
250 But you can't two blocks high.
251 Press the space bar once to jump at a constant height.
253 Jump: [Space]
255 Now try it to continue.]]
258 tutorial.texts.jumpover =
259 [=[Here is a slightly larger abyss. Luckily, you can also jump just far enough to
260 cross a gap of this width. Don't worry, the abyss is not deep enough to hurt you
261 when you fall down. There are stairs which lead back up here.
263 Jump: [Space]]=]
265 tutorial.texts.orientation =
266 [[From this point on, there will be branching paths. For orientation, we placed
267 some arrow signs. They just show a short text when you hover them, that's all.
269 You don't have to follow the sections in any particular order, with one exception,
270 for which you will be informed.]]
272 tutorial.texts.sneak =
273 [=[Sneaking is a special move. As long as you sneak, you walk slower, but you are
274 guaranteed to not accidentally fall off the edge of a block. This also allows you to
275 "lean over" in a sense.
276 To sneak, keep the sneak key pressed. As soon as you release the sneak key,
277 you walk at normal speed again. Be careful not releasing the sneak key when you
278 are at a ledge, you might fall!
280 Sneak: [Shift]
282 Keep in mind that the [Shift] key is used for a large number of other things in Minetest.
283 Sneaking only works when you are not in a liquid, stand on solid ground and are not at a
284 ladder.
286 You may try out sneaking at this little blocky pyramid.]=]
288 tutorial.texts.sneakjump =
289 [=[You can jump slightly higher if you jump while holding the sneak key.
291 Sneak: [Shift]
292 Jump: [Space]]=]
294 tutorial.texts.hotbar =
295 [[At the bottom of the screen you see 8 squares. This is called the 'hotbar'.
296 The hotbar allows you to quickly access some items from your inventory.
297 In our case, the upper 8 slots in your inventory.
298 You can change the selected item with the mouse wheel, if you have one, or with the
299 number keys.
301 Select previous item in hotbar: [Mouse wheel up]
302 Select next item in hotbar: [Mouse wheel down]
303 Select item #N in hotbar: the key with the number #N
305 The item you've seleted is also the item you wield. This will be important later for
306 tools, mining, building, etc.]]
309 tutorial.texts.eat =
310 [[In this chest you find some comestibles. Comestibles are items which instantly
311 heal you when eaten. This removes the item from your inventory.
312 To eat one, select the comestible in your hotbar, then click the left mouse button.
313 Unlike other items, you cannot punch or attack while holding a comestible. To be able
314 to attack, you have to select something else.
315 Of course, this does not have to be the only way to heal you.
317 Eat comestible: [Left mouse button]
319 Don't forget to take the gold ingot.]]
321 tutorial.texts.chest =
322 [[Treasure chests are a common sight in Minetest. They are actually not built-in
323 into the game.]]
325 tutorial.texts.damageblock =
326 [[Careful! These spikes hurt you when you stand inside, so don't walk into them.
327 Try to walk around and get the gold ingot.
329 They damage you every second you stand in them.
331 This is one of the many ways you can get hurt in Minetest.]]
333 tutorial.texts.ladder =
334 [[This is a ladder. Ladders help you to climb up great heights or to climb down safely.
335 To climb a ladder, go into the block occupied by the ladder and hold one of the
336 following keys:
338 Climb up ladder: [Space]
339 Climb down ladder: [Shift]
341 Note that sneaking and jumping do not work when you are at a ladder.]]
343 tutorial.texts.swim =
344 [[What you see here is a small swimming pool. You are able to swim and dive.
345 Diving usually costs you breath. While diving, 10 bubbles appear in the heads-up display.
346 These bubbles disappear over time while diving and when you are out of bubbles,
347 you slowly lose some health points. You have to back up to the surface from time to
348 time to restore the bubbles.
350 Movement in a liquid is slightly different than on solid ground:
352 Swim forwards: [W]
353 Swim backwards: [S]
354 Swim leftwards: [A]
355 Swim rightwards: [D]
356 Swim upwards: [Space]
357 Swim downwards: [Shift]
359 At the bottom of the pool lies a gold ingot. Try to get it!]]
362 tutorial.texts.dive =
363 [=[To get to the other side, you have to dive here. Don't worry, the tunnel is not
364 long. But don't stay too long in the water, or else you take damage.
365 At the bottom of the pool lies a gold ingot. Try to get it!
367 Swim forwards: [W]
368 Swim backwards: [S]
369 Swim leftwards: [A]
370 Swim rightwards: [D]
371 Swim upwards: [Space]
372 Swim downwards: [Shift]]=]
374 tutorial.texts.waterfall = ""..
375 [=[You can easily swim up this waterfall. Go into the water and hold the space bar until you're
376 at the top
378 Swim forwards: [W]
379 Swim backwards: [S]
380 Swim leftwards: [A]
381 Swim rightwards: [D]
382 Swim upwards: [Space]
383 Swim downwards: [Shift]]=]
385 tutorial.texts.liquidtypes =
386 [=[Liquids behave somewhat weirdly in Minetest. Actually, there are 2 kinds of liquids.
387 If you watched the waterfall closely, you may have noticed that there is a slight difference
388 between the water blocks that make the waterfall, and those up here in the basin.
390 Minetest distinguishes between liquid source and flowing liquid.
392 A liquid source block is always a full cube.
393 A flowing liquid block looks slightly different. Often, it is not a full cube, but has a more or less
394 triangular shape. Also, flowing liquids usually have an unique "flowing" animation, but this may
395 not be the case for all liquids.
397 Up in the basin, you see four rows of liquid sources, followed by one row of flowing
398 liquids, followed by the waterfall itself. The waterfall itself is solely made of flowing liquids.
400 Liquid sources generate flowing liquids around them. Liquid sources can also exist on their own.
401 Flowing liquids are not able to exist on their own. They have to originate from a liquid source.
402 If the liquid source is gone, or the way to one is blocked, the flowing liquid will slowly dry
403 out.
405 To the right of this sign is a special block. When used, it will block the liquid flow.
406 Use that block, being close enough and looking at it, and watch the waterfall dry out.
408 Use something: [Right mouse button]]=]
410 tutorial.texts.viscosity =
411 [[Minetest mods can introduce various liquids which differ in their properties.
412 Probably the most important property is their viscosity. Here you have some
413 pools which differ in their viscosity. Feel free to try them out.]]
415 tutorial.texts.pointing1 =
416 [[An important general concept in Minetest is pointing. As mentioned earlier,
417 there is a crosshair in the center of the screen.
419 You can point several things in Minetest:
421 - Blocks
422 - Dropped items
423 - Other players
424 - Many other things
426 You can only point one thing at once, or nothing at all. You can tell when
427 you point something if it is surrounded by a thin cuboid wireframe.
429 To point something, three conditions have to be met:
430 1. The thing in question must be pointable at all
431 2. Your crosshair must be exactly over the thing in question
432 3. You must be close enough to the thing
434 When a thing is pointed, you can do different stuff with it; e.g. collecting it,
435 punching it, building to it, etc. We come to all that later.
437 Now collect that apple from the small tree in front of this sign, and the gold bar.
438 To do that, you must point it and click with the left mouse button.]]
441 tutorial.texts.pointing2 =
442 [[The distance you need to point to things solely depends on the tool you carry.
443 Most tools share a default value but some tools may have a longer or shorter distance.
445 At the moment, your only "tool" is the hand. It was good enough to collect the apple
446 from the small tree.
448 Above this sign hang some apples, but you cannot reach them by normal means. At the
449 wall in front of this sign lies a special example tool which you can use to retrieve the apple
450 from afar.
452 To take the tool, point to it and click the left mouse button. Then select it with the
453 mouse wheel or the number keys. You will learn more about tools in a different section.]]
455 tutorial.texts.health =
456 [[Unless you have damage disabled, all players start with 20 hit points (HP), represented
457 by ten hearts in the heads-up display. One HP is represented by half a heart in this
458 tutorial, but the actual representation can vary from subgame to subgame.
460 You can take damage for the following reasons (including, but not limited to):
461 - Falling too deep
462 - Standing in a block which hurts you
463 - Attacks from other players
464 - Staying too long in a liquid
466 In this tutorial, you can regain health by eating a comestible. This is only an example,
467 mods and subgames may come with other mechanisms to heal you.
469 When you lose all your hit points, you die. Death is normally not really that bad in Minetest.
470 When you die, you will usually lose all your possessions. You are able to put yourself
471 into the world immediately again. This is called "respawning". Normally you appear at a
472 more or less random location.
473 In the tutorial you can die, too, but don't worry about that. You will
474 respawn at a special location you can't normally reach and keep all your posessions.
475 Subgames may introduce special events on a player's death.]]
477 tutorial.texts.death =
478 [[Oops! So it seems you just have died. Don't worry, you don't have lost any of your
479 possessions and you have been revived. You are still in Tutorial World at a different
480 location.
482 You have arrived at the so-called respawn location of Tutorial World. You will
483 always appear here after you died. This is called "respawning". In most worlds,
484 however, you will respawn in a slightly randomized location.
486 The tutorial uses a so-called fixed spawn point, so you respawn always at the same
487 spot. This is unusual for singleplayer worlds, but in online play, some servers
488 use fixed spawn points, too.
490 Under normal conditions you would have lost all or a part of your possessions or some
491 other bad thing would have happened to you. But not here, this is a tutorial.
493 To continue, just drop out at the end of that gangway. The drop is safe.]]
498 tutorial.texts.items =
499 [[Throughout your journey, you will probably collect many items. Once you collected
500 them, blocks are considered to be items, too.
502 Items can be stored in your inventory and selected with the hotbar (see the other signs).
503 You can wield any items; you can even punch with almost any item to hurt enemies.
504 Usually, you will deal a minimal default damage with most items. Even if you do not hold,
505 an item at all.
506 If you don't want to have an item anymore, you can always throw it away. Likewise,
507 you can collect items which lie around by pointing and leftclicking them.
509 Collect item: [Left mouse button]
510 Drop carried item stack: [Q]
511 Drop single item from carried item stack: [Shift] + [Q]
513 On the table at the right to this sign lies an item stack of 50 rocks so you have some items,
514 to test out the inventory.]]
516 tutorial.texts.tools =
517 [[A tool is a special kind of item.
518 Tools can be used for many things, such as:
519 - Breaking blocks
520 - Collecting liquids
521 - Rotating blocks
522 - Many others!
523 The number of tools which are possible in Minetest is innumberable and are
524 too many to cover in this tutorial.
525 But at least we will look at a very common and important tool type: mining tools,
526 We will come to that in the mining section.
528 Many tools wear off and get destroyed after you used them for a while. In an
529 inventory the tool's "health" is indicated by a colored bar
531 Tools may be able to be repaired, see the sign about repairing.]]
533 tutorial.texts.inventory =
534 [[The inventory menu usually contains the player inventory. This allows you
535 to carry along items throughout the world.
537 Every inventory is made out of slots where you can store items in. You can store one
538 entire stack of items per slot, the only condition is that the items are of the same
539 type. In this tutorial all items except for tools stack up to 99 items, but this number
540 can vary in actual subgames.
542 Here are the controls which explain how to move around the items within the inventory:
544 In the game:
545 Open inventory menu: [I]
547 When the inventory is opened and you don't hold any items:
548 Take item stack: [Left mouse button]
549 Take 10 items from item stack: [Middle mouse button]
550 Take half item stack: [Right mouse button]
552 When you took an item stack in the inventory:
553 Put item stack: [Left mouse button]
554 Put 10 items from item stack: [Middle mouse button]
555 Put single item from item stack: [Right mouse button]
557 You can also drop an item stack by holding it in the inventory, then clicking anywhere
558 outside of the window.]]
560 tutorial.texts.chest =
561 [[This is a chest. You can view its contents by right-clicking it. In the menu you will see
562 two inventories, on the upper part the chest inventory and on the lower part the player
563 inventory. Exchanging items works exactly the same as in the inventory menu.]]
566 tutorial.texts.build =
567 [[Another important task in Minetest is building blocks.
568 "Building" here refers to the task of placing one block in your possession onto
569 another block in the world.
570 Unlike mining, building a block happens instantanous. To build, select a block in your
571 hotbar, point to any block in the world and press the right mouse button.
572 Your block will be immediately placed on the pointed side.
573 It is important that the block you want to build to is pointable. This means you cannot build
574 next to or on liquids by normal means.
576 Build on ordinary block: [Right mouse button]
578 Try to get up to that little hole by using the wood blocks in the chest. There is another
579 gold ingot waiting for you.]]
581 tutorial.texts.mine =
582 [[Mining is a method to remove a single block with a mining tool. It is a very important
583 task in Minetest which you will use often.
585 (It is recommended that you go to the crafting and items house first. It is right in front of
586 this sign.)
588 To be able to mine a block, you need
590 1. to have minable block, after all,
591 2. to point on the block and
592 3. to carry an appropriate tool.
594 Mine: [Left mouse button]
596 When you are ready, hold the left mouse button while pointing the block. Depending on
597 the block type and the tool properties, this can take some time. Some tools are fast with
598 some particular block types, some other tools may be slower to mine other block types.
599 If you do not carry an appropriate tool, you are not able to mine the block at all.
600 You can tell that you are actually mining when you see cracks or some other animation
601 on the block in question.
603 When done mining, blocks will often add one or more items to your inventory. This is called
604 the "drop" of a block and depends on the block type. Now try to mine those large cubes in
605 this area, using different tools. Note that all blocks here are just examples to show you
606 different kinds of drops.]]
608 tutorial.texts.mine_cobble =
609 [[This is cobblestone. You can mine it with a pickaxe.
610 This cobblestone will always drop itself, that means, cobblestone. Dropping itself is the
611 usual dropping behaviour of a block, throughout many subgames.]]
613 tutorial.texts.mine_wood =
614 [[These are wooden planks. In the tutorial, you can only mine those blocks with an axe.
615 Wooden planks drop themselves.
617 In Minetest, we use the term "mining" in a general sense, regardless of the material.]]
619 tutorial.texts.mine_conglomerate =
620 [[This is a cube of conglomerate. You need a pickaxe to mine it.
621 Conglomerate drops something based on probability. Conglomerate randomly drops between 1
622 and 5 rocks, when mined.]]
624 tutorial.texts.mine_glass =
625 [[This is some weak glass. You can break it with your bare hands. Or you can use your pickaxe,
626 which is faster. Note that it looks slightly different than the other glass in this world.
627 These glass blocks don't drop anything.]]
629 tutorial.texts.mine_stone =
630 [[This is stone. You need a pickaxe to mine it. When mined, stone will drop cobblestone.]]
632 tutorial.texts.mine_immortal =
633 [[There can always be some blocks which are not minable by any tool. In our tutorial, all
634 those castle walls can't me mined, for example.]]
636 tutorial.texts.craft1 =
637 [[Crafting is the task of taking several items and combining them to form a new item.
638 Crafting is another important task in Minetest.
640 To craft something, you need a few items and a so-called crafting grid.
642 In this tutorial, you have a grid of size 3 times 3 in your inventory.
643 Let's get right into crafting:
645 1. Take 3 sheets of paper from the chest next to this sign.
646 2. Open the inventory menu with [I].
647 3. Place the paper in the crafting grid so that they form a 1×3 vertical line.
648 4. A book should appear in the output slot. Click on it to take it,
649 then put it in your player inventory.
651 This process consumes the paper.
652 When you have the book in your inventory, go on with the next sign.]]
654 tutorial.texts.craft2 =
655 [[To craft the book you have used a so-called crafting recipe. You must know the crafting
656 recipes as well so you can craft.
658 The crafting recipe you used in particular is a so-called shaped recipe. This means the
659 pattern you place in the crafting grid matters, but you can move the entire pattern
660 freely.
662 There is another kind of crafting recipe: Shapeless.
663 Shapeless recipes only care about which items you place in the crafting grid, but not in
664 which pattern. In the next chest you find some wheat. Let's make dough from it! For this,
665 you have to place at least 1 wheat in 4 different slots, but the other slots must be empty.
666 What is special about this recipe is that you can place them anywhere in the grid.
668 When you got your dough, go on with the next sign.]]
670 tutorial.texts.craft3 =
671 [[Do you got your dough? Good.
673 You may have noticed that crafting always consumes one item from each occupied slot
674 of the crafting grid. This is true for all crafting recipes.
675 You can speed crafting up a bit when you click with the middle mouse button on the
676 item in the output slot. Doing so will attempt to do the same craft up to 10 times,
677 instead of just once.
679 Feel free to try it with the remaining wheat or just go on with the next sign.]]
681 tutorial.texts.craft4 =
682 [[Another important thing to know about crafting are so-called groups. Crafting recipes do
683 not always require you to use the exactly same items every time.
684 This tutorial has a special recipe for books. In the chest, you will find paper in 4
685 different colors. You can also make a book by placing 3 paper sheets of any color
686 in a vertical line.
687 The paper color does not matter here, you can use only white paper, only orange paper
688 or even mix it. What is important here are the occupied slots.
689 This is possible because all 4 types of (example) paper belong to the same group and
690 our book recipe accepts not only white paper, but any paper of that group.
692 Feel free to experiment a bit around with this.]]
694 tutorial.texts.smelt =
695 [[This is a furnace. Furnaces can be used to turn a smeltable item with help of a fuel
696 to a new item. Many items can be furnace fuels, but not all. A few items are smeltable.
698 In order to operate a furnace, you have to put the smeltable item into the 'Source' slot
699 and the fuel into the 'Fuel' slot.
700 As soon as the items have been placed, the furnace automatically starts to smelt the
701 items. The furnace becomes active and consumes an item in the fuel slot. The flame
702 goes on and will continue burning for a given time. The time depends on the fuel type.
703 Some fuels burn very short, and other burn longer. In the furnace menu, the burn time
704 is indicated by the flame symbol. As soon as the flame goes out, the furnace may
705 continue burning if there is still fuel and smeltable material in the furnace,
706 otherwise, the furnace becomes inactive again.
707 The smeltable material has to be exposed to the flame for a given time as well. This
708 time depends on the type of the material, too. Some material smelt faster than others.
709 You can see the smelting progress of a single item on the progress arrow. If one item
710 has been smelt, the result goes to one of the output slots, where you can take it.
712 In the left chest you find some fuels and in the right chest you find some materials to
713 smelt. Feel free to experiment with the furnace a bit. Smelt the gold lump to receive
714 this station's gold bar.
716 Again, this furnace is just an example; the exact operation may differ slightly from
717 subgame to subgame.]]
719 tutorial.texts.repair =
720 [[Some subgames may come with a special recipe which allows you to repair your tools.
721 In those, repairing works always the same way:
722 Place two more or less worn out tools of the same kind into the crafting crid and
723 take the result. The result is a new tool which is slightly repaired by a fixed percentage.
725 Of course, this tutorial comes with such a recipe. The chest next to this sign stores
726 some damaged tools which you may try to repair now.]]
729 tutorial.texts.use =
730 [=[You will often meet some blocks you can use. Something special happens when you
731 right-click while pointing on them.
732 In fact, you already used such blocks: All the signs you read are "usable" blocks.
734 There is a strange device next to this sign. Use it and see what happens.
736 Use usable block: [Right mouse button]]=]
739 tutorial.texts.basic_end =
740 [[If you think you have enough of this tutorial, you can leave at any time. There are
741 13 gold ingots at the stations to be found, to help you keep track.
743 You can find the gold ingots at the following stations:
744 - Ladders
745 - Sneaking
746 - Swimming
747 - Diving
748 - Waterfall
749 - Viscosity
750 - Comestibles and Eating
751 - Pointing
752 - Crafting
753 - Smelting
754 - Mining
755 - Building
756 - Damage and Health
758 If you've got 13 gold ingots (in total), you probably know now everything which can be
759 learned from this tutorial. Collecting the gold ingots is optional.
761 After you closed this dialog, you can press [Esc] to open the pause menu and return
762 to the main menu or quit Minetest.
764 In the next room there are some further signs with information, but it is entirely optional
765 and not related to gameplay.]]
767 tutorial.texts.fallout =
768 [[You somehow managed to fall from the castle or got otherwise below it!
769 How did you do that?
771 Anyways, you've got teleported back to the starting location. Whatever you did, be more
772 careful next time.]]
774 tutorial.texts.first_gold =
775 [[You have collected your first gold ingot. Those will help you to keep track in this tutorial.
776 There are 14 gold ingots in this tutorial.
778 There is a gold ingot at every important station. If you collected all ingots, you are
779 done with the tutorial, but collecting the gold ingots is not mandatory.]]
781 tutorial.texts.last_gold =
782 [[You have collected all the gold ingots in this tutorial.
784 This means you have now travelled to each station. If you read and understood everything,
785 you have learned everything which can be learned from this tutorial.
787 If this is the case, you are finished with this tutorial and can leave now. But feel
788 free to stay in this world to explore the area a bit further.
790 You may also want to visit the Good-Bye room, which has a few more informational
791 signs with supplemental information, but nothing of is is essential or gameplay-relevant.
793 If you want to stay, you leave later by pressing [Esc] to open the pause menu and then
794 return to the main menu or quit Minetest.]]
796 tutorial.texts.first_diamond =
797 [[Great, you have found and collected a hidden diamond! In Tutorial World, there are 12 hidden
798 diamonds. Can you find them all? The first diamond may have been easy to collect, but the
799 remaining 11 diamonds probably won't be that easy.
801 If you manage to find them all, you will be awarded a symbolic prize.]]
803 tutorial.texts.last_diamond =
804 [[Congratulations!
805 You have collected all the diamonds of Tutorial World!
807 To recognize this achievement, you have been awarded with a diamond cup. It has been placed in
808 the Good-Bye Room for you.]]
811 tutorial.texts.controls =
812 [[To recap, here is an overview over the most important default controls:
814 Move forwards: [W]
815 Move left: [A]
816 Move backwards: [S]
817 Move right: [D]
818 Jump: [Space]
819 Sneak: [Shift]
820 Move upwards (ladder/liquid): [Space]
821 Move downwards (ladder/liquid): [Shift]
823 Toggle camera mode: [F7]
825 Select item in hotbar: [Mouse wheel]
826 Select item in hotbar: [0] - [9]
827 Inventory menu: [I]
829 Collect pointed item: [Left mouse button]
830 Drop item stack: [Q]
831 Drop single item: [Shift] + [Q]
833 Punch: [Left mouse button]
834 Mine: [Left mouse button]
835 Build/use: [Right mouse button]
836 Build: [Shift] + [Right mouse button]
838 Abort/open pause menu: [Esc]
840 You can review a shorter version of the controls in the pause menu.]]
843 tutorial.texts.online =
844 [[You may want to check out these online resources related to Minetest:
846 Official homepage of Minetest: <http://minetest.net/>
847 The main place to find the most recent version of Minetest.
849 Community wiki: <http://wiki.minetest.net/>
850 A community-based documentation website for Minetest. Anyone with an account can edit
851 it! It also features a documentation of the default game, which was NOT covered by
852 this tutorial.
854 Webforums: <http://forums.minetest.net/>
855 A web-based discussion platform where you can discuss everything related to Minetest.
856 This is also a place where player-made mods and subgames are published and
857 discussed. The discussions are mainly in English, but there is also space for
858 discussion in other languages.
860 Chat: <irc://irc.freenode.net#minetest>
861 A generic Internet Relay Chat channel for everything related to Minetest where people can
862 meet to discuss in real-time.
863 If you do not understand IRC, see the Community Wiki for help.]]
866 tutorial.register_infosign("intro", "Introduction", tutorial.texts.intro)
867 tutorial.register_infosign("minetest", "Minetest", tutorial.texts.minetest)
868 tutorial.register_infosign("cam", "Player Camera", tutorial.texts.cam)
869 tutorial.register_infosign("runover", "Small Abysses", tutorial.texts.runover)
870 tutorial.register_infosign("jumpup", "Jumping (1)", tutorial.texts.jumpup)
871 tutorial.register_infosign("jumpover", "Jumping (2)", tutorial.texts.jumpover)
872 tutorial.register_infosign("sneak", "Sneaking", tutorial.texts.sneak)
873 tutorial.register_infosign("sneakjump", "Sneak-jumping", tutorial.texts.sneakjump)
874 tutorial.register_infosign("orientation", "Information about the following tutorial sections", tutorial.texts.orientation)
875 tutorial.register_infosign("hotbar", "Hotbar", tutorial.texts.hotbar)
876 tutorial.register_infosign("eat", "Comestibles and Eating", tutorial.texts.eat)
877 tutorial.register_infosign("chest", "Chests", tutorial.texts.chest)
878 tutorial.register_infosign("damageblock", "Blocks Which Hurt You", tutorial.texts.damageblock)
879 tutorial.register_infosign("ladder", "Climbing Ladders", tutorial.texts.ladder)
880 tutorial.register_infosign("swim", "Swimming", tutorial.texts.swim)
881 tutorial.register_infosign("dive", "Diving", tutorial.texts.dive)
882 tutorial.register_infosign("waterfall", "Swimming up a Waterfall", tutorial.texts.waterfall)
883 tutorial.register_infosign("viscosity", "Viscosity", tutorial.texts.viscosity)
884 tutorial.register_infosign("liquidtypes", "Liquid sources and flowing liquids", tutorial.texts.liquidtypes)
885 tutorial.register_infosign("pointing1", "Pointing (1)", tutorial.texts.pointing1)
886 tutorial.register_infosign("pointing2", "Pointing (2)", tutorial.texts.pointing2)
887 tutorial.register_infosign("health", "Health and Damage", tutorial.texts.health)
888 tutorial.register_infosign("death", "Death and Respawning", tutorial.texts.death)
889 tutorial.register_infosign("items", "Items", tutorial.texts.items)
890 tutorial.register_infosign("tools", "Tools", tutorial.texts.tools)
891 tutorial.register_infosign("inventory", "Using the Inventory", tutorial.texts.inventory)
892 tutorial.register_infosign("chest", "Comment About Chests", tutorial.texts.chest)
893 tutorial.register_infosign("build", "Building Some Blocks", tutorial.texts.build)
894 tutorial.register_infosign("mine", "Mining blocks", tutorial.texts.mine)
895 tutorial.register_infosign("mine_cobble", "Mining example: Cobblestone", tutorial.texts.mine_cobble)
896 tutorial.register_infosign("mine_stone", "Mining example: Stone", tutorial.texts.mine_stone)
897 tutorial.register_infosign("mine_conglomerate", "Mining example: Conglomerate", tutorial.texts.mine_conglomerate)
898 tutorial.register_infosign("mine_wood", "Mining example: Wooden Planks", tutorial.texts.mine_wood)
899 tutorial.register_infosign("mine_glass", "Mining example: Weak glass", tutorial.texts.mine_glass)
900 tutorial.register_infosign("mine_immortal", "Unminable blocks", tutorial.texts.mine_immortal)
901 tutorial.register_infosign("blocks", "Special blocks", tutorial.texts.blocks)
902 tutorial.register_infosign("disable_jump", "No-jumping blocks", tutorial.texts.disable_jump)
903 tutorial.register_infosign("falling_node", "Falling blocks", tutorial.texts.falling_node)
904 tutorial.register_infosign("attached_node", "Attached blocks", tutorial.texts.attached_node)
905 tutorial.register_infosign("use", "Using blocks", tutorial.texts.use)
906 tutorial.register_infosign("craft1", "Crafting Basics", tutorial.texts.craft1)
907 tutorial.register_infosign("craft2", "Crafting using Shapeless Recipes", tutorial.texts.craft2)
908 tutorial.register_infosign("craft3", "Crafting Faster", tutorial.texts.craft3)
909 tutorial.register_infosign("craft4", "Crafting Groups", tutorial.texts.craft4)
910 tutorial.register_infosign("smelt", "Furnace Operation Instructions", tutorial.texts.smelt)
911 tutorial.register_infosign("repair", "Repairing Tools", tutorial.texts.repair)
912 tutorial.register_infosign("basic_end", "End of the Basic Tutorial", tutorial.texts.basic_end)
913 tutorial.register_infosign("controls", "Controls Overview", tutorial.texts.controls)
914 tutorial.register_infosign("online", "Online Resources", tutorial.texts.online)
915 tutorial.register_infosign("subgame", "Subgames", tutorial.texts.subgame)
917 minetest.register_node("tutorial:wall", {
918 description = S("reinforced wall"),
919 tiles = {"default_stone_brick.png"},
920 is_ground_content = true,
921 groups = {immortal=1},
922 sounds = default.node_sound_stone_defaults(),
925 minetest.register_node("tutorial:reinforced_glass", {
926 description = S("reinforced glass"),
927 drawtype = "glasslike",
928 tiles = {"tutorial_reinforced_glass.png"},
929 inventory_image = minetest.inventorycube("tutorial_reinforced_glass.png"),
930 paramtype = "light",
931 sunlight_propagates = true,
932 groups = { immortal=1 },
933 sounds = default.node_sound_glass_defaults(),
936 minetest.register_node("tutorial:weak_glass", {
937 description = S("weak glass"),
938 drawtype = "glasslike",
939 tiles = {"tutorial_weak_glass.png"},
940 inventory_image = minetest.inventorycube("tutorial_weak_glass.png"),
941 paramtype = "light",
942 sunlight_propagates = true,
943 groups = { cracky=3, oddly_breakable_by_hand=1 },
944 drop = "",
945 sounds = default.node_sound_glass_defaults(),
949 minetest.register_tool("tutorial:snatcher", {
950 description = S("apple snatcher"),
951 inventory_image = "tutorial_snatcher.png",
952 wield_image = "tutorial_snatcher.png",
953 wield_scale = { x = 1, y = 1, z = 1 },
954 range = 10,
955 tool_capabilities = {},
958 --[[ A special switch which, when flipped, exchanges day for night and vice versa. ]]
959 minetest.register_node("tutorial:day", {
960 description = S("day/night switch (day)"),
961 tiles = { "tutorial_day.png" },
962 groups = {immortal=1},
963 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
964 minetest.set_timeofday(0)
965 minetest.set_node(pos, {name="tutorial:night"})
968 minetest.register_node("tutorial:night", {
969 description = S("day/night switch (night)"),
970 tiles = { "tutorial_night.png" },
971 groups = {immortal=1},
972 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
973 minetest.set_timeofday(0.5)
974 minetest.set_node(pos, {name="tutorial:day"})
978 --[[ A special switch which "activates" and "deactivates" the waterfall in Tutorial World.
979 It only works on a prepared map! ]]
980 minetest.register_node("tutorial:waterfall_on", {
981 description = S("waterfall switch (on)"),
982 tiles = { "tutorial_waterfall_on.png" },
983 groups = {immortal=1},
984 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
985 local wpos = { y = 5, z = 86 }
986 for x=33,46 do
987 wpos.x = x
988 minetest.set_node(wpos, {name="tutorial:wall"})
990 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_off"})
991 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_off"})
994 minetest.register_node("tutorial:waterfall_off", {
995 description = S("waterfall switch (off)"),
996 tiles = { "tutorial_waterfall_off.png" },
997 groups = {immortal=1},
998 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
999 local wpos = { y = 5, z = 86 }
1000 for x=33,46 do
1001 wpos.x = x
1002 minetest.remove_node(wpos)
1004 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_on"})
1005 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_on"})
1009 -- Ruler (used in sneaking section)
1010 minetest.register_node("tutorial:ruler", {
1011 description = S("ruler"),
1012 drawtype = "signlike",
1013 selection_box = {
1014 type = "wallmounted",
1015 wall_side = { -0.5, -0.5, 1/16, -0.4, 0.5, 0.5 },
1017 walkable = false,
1018 tiles = { "tutorial_ruler.png" },
1019 inventory_image = "tutorial_ruler.png",
1020 wield_image = "tutorial_ruler.png",
1021 paramtype = "light",
1022 paramtype2 = "wallmounted",
1023 sunlight_propagates = true,
1024 groups = {immortal=1, attached_node=1},
1028 --[[ Tutorial cups, awarded for achievements ]]
1029 tutorial.cupnodebox = {
1030 type = "fixed",
1031 fixed = {
1032 {-0.3,-0.5,-0.3,0.3,-0.4,0.3}, -- stand
1033 {-0.1,-0.4,-0.1,0.1,0,0.1}, -- handle
1034 {-0.3,0,-0.3,0.3,0.1,0.3}, -- cup (lower part)
1035 -- the 4 sides of the upper part
1036 {-0.2,0.1,-0.3,0.2,0.5,-0.2},
1037 {-0.2,0.1,0.2,0.2,0.5,0.3},
1038 {-0.3,0.1,-0.3,-0.2,0.5,0.3},
1039 {0.2,0.1,-0.3,0.3,0.5,0.3},
1043 tutorial.cupselbox = {
1044 type = "fixed",
1045 fixed = {
1046 {-0.3,-0.5,-0.3,0.3,-0.4,0.3}, -- stand
1047 {-0.1,-0.4,-0.1,0.1,0,0.1}, -- handle
1048 {-0.3,0,-0.3,0.3,0.5,0.3}, -- upper part
1052 function tutorial.goldinfo(pos)
1053 local meta = minetest.get_meta(pos)
1054 meta:set_string("infotext", S("This golden cup has been awarded for finishing the tutorial."))
1057 function tutorial.diamondinfo(pos)
1058 local meta = minetest.get_meta(pos)
1059 meta:set_string("infotext", S("This diamond cup has been awarded for collecting all hidden diamonds."))
1062 --[[ awarded for collecting all gold ingots ]]
1063 minetest.register_node("tutorial:cup_gold", {
1064 description = S("golden cup"),
1065 tiles = { "default_gold_block.png" },
1066 paramtype = "light",
1067 drawtype = "nodebox",
1068 node_box = tutorial.cupnodebox,
1069 selection_box = tutorial.cupselbox,
1070 groups = { immortal = 1 },
1071 on_construct = tutorial.goldinfo,
1074 --[[ awarded for collecting all diamonds ]]
1075 minetest.register_node("tutorial:cup_diamond", {
1076 description = S("diamond cup"),
1077 tiles = { "default_diamond_block.png" },
1078 paramtype = "light",
1079 drawtype = "nodebox",
1080 node_box = tutorial.cupnodebox,
1081 selection_box = tutorial.cupselbox,
1082 groups = { immortal = 1 },
1083 on_construct = tutorial.diamondinfo,
1086 minetest.register_abm({
1087 nodenames = {"tutorial:cup_gold"},
1088 interval = 5,
1089 chance = 1,
1090 action = tutorial.goldinfo,
1093 minetest.register_abm({
1094 nodenames = {"tutorial:cup_diamond"},
1095 interval = 5,
1096 chance = 1,
1097 action = tutorial.diamondinfo,
1100 --[[ This function shows a simple dialog window with scrollable text
1101 name: name of the player to show the formspec to
1102 caption: Caption of the dialog window (not escaped)
1103 text: The text to be shown. Must be escaped manually for formspec, an unescaped
1104 comma generates a line break.
1106 function tutorial.show_default_dialog(name, caption, text)
1107 local formspec = "size[12,6]"..
1108 "label[-0.15,-0.4;"..minetest.formspec_escape(caption).."]"..
1109 "tablecolumns[text]"..
1110 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1111 "table[0,0.25;12,5.2;text_table;"..
1112 tutorial.convert_newlines(minetest.formspec_escape(S(text)))..
1113 "]"..
1114 "button_exit[4.5,5.5;3,1;close;"..S("Close").."]"
1115 minetest.show_formspec(name, "tutorial_dialog", formspec)
1118 minetest.register_on_joinplayer(function(player)
1119 local formspec = nil
1120 if(minetest.is_singleplayer() == false) then
1121 formspec = "size[12,6]"..
1122 "label[-0.15,-0.4;"..minetest.formspec_escape(S("Warning: You're not playing in singleplayer mode")).."]"..
1123 "tablecolumns[text]"..
1124 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1125 "table[0,0.25;12,5.2;creative_text;"..
1126 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.notsingleplayer)))..
1127 "]"..
1128 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
1129 "button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
1130 elseif(minetest.setting_getbool("creative_mode")) then
1131 formspec = "size[12,6]"..
1132 "label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
1133 "tablecolumns[text]"..
1134 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1135 "table[0,0.25;12,5.2;creative_text;"..
1136 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.creative)))..
1137 "]"..
1138 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
1139 "button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
1141 else
1142 if(tutorial.state.first_join==true) then
1143 formspec = "size[12,6]"..
1144 "label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
1145 "tablecolumns[text]"..
1146 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1147 "table[0,0.25;12,5.2;intro_text;"..
1148 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.intro)))..
1149 "]"..
1150 "button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
1152 tutorial.state.first_join = false
1153 tutorial.save_state()
1155 if(formspec~=nil) then
1156 minetest.show_formspec(player:get_player_name(), "intro", formspec)
1161 minetest.register_on_player_receive_fields(function(player, formname, fields)
1162 if(fields.leave) then
1163 minetest.kick_player(player:get_player_name(), S("You have voluntarily exited the tutorial."))
1165 if(fields.gotostart) then
1166 tutorial.back_to_start(player)
1168 if(fields.gotoend) then
1169 tutorial.go_to_end(player)
1171 end)
1173 tutorial.steptimer = 0
1174 minetest.register_globalstep(function(dtime)
1175 tutorial.steptimer = tutorial.steptimer + dtime
1176 local players = minetest.get_connected_players()
1177 if(tutorial.steptimer > 2) then
1178 for p=1,#players do
1179 local player = players[p]
1180 local name = player:get_player_name()
1181 if(player:getpos().y < -12 and (not minetest.setting_getbool("creative_mode"))) then
1182 -- teleport players back to the start when they fell away
1183 tutorial.back_to_start(player)
1184 tutorial.show_default_dialog(name, S("You fell from the castle!"), tutorial.texts.fallout)
1186 else
1187 local inv = player:get_inventory()
1188 local state_changed = false
1190 if(tutorial.state.first_gold ~= true) then
1191 local gold_stack = ItemStack("default:gold_ingot 1")
1192 if(inv:contains_item("main", gold_stack)) then
1193 tutorial.show_default_dialog(
1194 name,
1195 S("Gold ingots in the tutorial"),
1196 tutorial.texts.first_gold
1198 tutorial.state.first_gold = true
1199 state_changed = true
1202 if(tutorial.state.last_gold ~= true) then
1203 local gold_stack = ItemStack("default:gold_ingot "..tostring(tutorial.gold))
1204 if(inv:contains_item("main", gold_stack)) then
1205 local formspec = "size[12,6]"..
1206 "label[-0.15,-0.4;"..minetest.formspec_escape(S("You've finished the tutorial!")).."]"..
1207 "tablecolumns[text]"..
1208 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1209 "table[0,0.25;12,5.2;creative_text;"..
1210 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.last_gold)))..
1211 "]"..
1212 "button_exit[0.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
1213 "button_exit[4.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"..
1214 "button_exit[8.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
1216 minetest.show_formspec(name, "tutorial_last_gold", formspec)
1218 minetest.set_node({x=19,y=2,z=72}, {name="tutorial:cup_gold"})
1219 tutorial.state.last_gold = true
1220 state_changed = true
1224 if(tutorial.state.first_diamond ~= true) then
1225 local diamond_stack = ItemStack("default:diamond 1")
1226 if(inv:contains_item("main", diamond_stack)) then
1227 tutorial.show_default_dialog(
1228 name,
1229 S("You found a hidden diamond!"),
1230 tutorial.texts.first_diamond
1232 tutorial.state.first_diamond = true
1233 state_changed = true
1236 if(tutorial.state.last_diamond ~= true) then
1237 local diamond_stack = ItemStack("default:diamond "..tostring(tutorial.diamonds))
1238 if(inv:contains_item("main", diamond_stack)) then
1239 local formspec = "size[12,6]"..
1240 "label[-0.15,-0.4;"..minetest.formspec_escape(S("You have collected all hidden diamonds!")).."]"..
1241 "tablecolumns[text]"..
1242 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1243 "table[0,0.25;12,5.2;last_diamond_text;"..
1244 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.last_diamond)))..
1245 "]"..
1246 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
1247 "button_exit[6.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
1248 minetest.show_formspec(name, "tutorial_last_diamond", formspec)
1250 minetest.set_node({x=19,y=2,z=74}, {name="tutorial:cup_diamond"})
1251 tutorial.state.last_diamond = true
1252 state_changed = true
1256 if(state_changed) then
1257 tutorial.save_state()
1261 tutorial.steptimer = 0
1263 end)
1265 function tutorial.back_to_start(player)
1266 player:setpos({x=42,y=0.5,z=28})
1269 function tutorial.go_to_end(player)
1270 player:setpos({x=23,y=0.5,z=74})
1273 --[[
1274 FIXME: This does not work in 0.4.10 thanks to a bug. Uncomment this as soon as
1275 set_physics_override gets fixed
1277 function tutorial.disable_sneak_glitch(player)
1278 player:set_physics_override({sneak_glitch=false, sneak=false})
1281 minetest.register_on_newplayer(tutorial.disable_sneak_glitch)
1282 minetest.register_on_joinplayer(tutorial.disable_sneak_glitch)
1283 minetest.register_on_respawnplayer(tutorial.disable_sneak_glitch)
1287 --[[
1288 Helper tools for sign text extracting
1289 must be called with /lua from luacmd
1290 An ugly, quick and dirty hack.
1291 TODO: Toss away intllib in favor of gettext as soon as possible
1294 function tutorial.convert_newlines_for_intllib(str)
1295 local function convert(s)
1296 return s:gsub("\n", function(slash, what)
1297 return "\\n"
1298 end)
1301 return convert(str)
1304 function tutorial.extract_texts()
1305 local filepath = minetest.get_modpath("tutorial").."/locale/template_texts.txt"
1306 local file = io.open(filepath, "w")
1307 if(file) then
1308 for k,v in pairs(tutorial.texts) do
1309 file:write("# Tutorial text: "..k.."\n")
1310 file:write(tutorial.convert_newlines_for_intllib(v).."\n\n")
1312 else
1313 minetest.log("error", "[tutorial] An attempt to write into "..filepath.." failed.")
1315 io.close(file)