Add sneak-jumping technique
[minetest_tutorial_subgame.git] / mods / tutorial / init.lua
bloba35cfdfe67366fd67a7932ee1552b79f12b84f2a
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 }
126 -- Number of gold ingots/lumps
127 tutorial.gold = 13
129 -- Number of hidden diamonds
130 tutorial.diamonds = 12
134 tutorial.texts = {}
135 tutorial.texts.intro =
136 [[Welcome! This tutorial will teach you the most crucial basics of Minetest.
137 This tutorial assumes that you have not changed the default keybindings yet.
139 Let's start for the most important keybindings right now:
141 Look around: Move the mouse
142 Walk forwards: [W]
143 Strafe left: [A]
144 Walk backwards: [S]
145 Strafe right: [D]
146 Action: [Right mouse button]
147 Pause menu (you can exit the game here): [Esc]
149 You will find signs with more introductionary texts throughout this tutorial.
150 The "action" key has many uses. For now, let's just say you need it to read
151 the signs. Look at one and right-click it to read it.
153 To look at a sign, make sure you are close enough to it and the crosshair in the
154 center of the screen points directly on the sign.
156 You can exit the tutorial at any time, the world will be automatically saved.
158 Now feel free to walk around a bit and read the other signs to learn more.]]
160 tutorial.texts.minetest =
161 [[Minetest itself is not a game, it is a game engine.
162 To be able to actually play it, you need something called a "Minetest game",
163 sometimes also called "subgame" or just "game". In this tutorial, we use the term,
164 "subgame".
166 Don't worry, Minetest comes pre-installed with a rather simple default subgame, oddly,
167 also called "Minetest"
169 This tutorial teaches you the basics of Minetest (the engine), things which are true for
170 all subgames. This tutorial does not teach you how to play a particular subgame, not
171 even the default one.
173 Minetest as well as the default subgame are unfinished at the moment, so please forgive
174 us when not everything works out perfectly.]]
176 tutorial.texts.subgame =
177 [[Now since you probably now the basics, you may want to actually play or build something.
178 Minetest comes bundled with a default subgame, which you may try out now.
179 Sadly, there is currently no tutorial for the default subgame.
180 You may want to read the "Getting Started" section of the Community Wiki,
181 which is more specific about the default subgame.
182 Said document can be found at:
184 <http://wiki.minetest.net/Getting_Started>
186 Alternatively, you may check out one of the subgames which are shared on the Minetest forums.]]
189 tutorial.texts.creative =
190 [[The creative mode is turned on. If you are here to learn how to play Minetest,
191 you should probably leave now, turn creative mode off and restart the
192 tutorial.
194 Roughly spoken, creative mode is for messing around with the game without
195 the normal gameplay restraints.
197 You can leave now by pressing "Leave tutorial", or later, by pressing [Esc].]]
199 tutorial.texts.notsingleplayer =
200 [[You are now playing the tutorial in multiplayer mode.
201 But this tutorial is optimized for the singleplayer mode.
202 This tutorial does not work properly with more than 1 player.
204 Unless you are sure no other players will join, you should
205 leave now and start the tutorial in singleplayer mode.]]
207 tutorial.texts.cam =
208 [=[Minetest has 3 different camera modes which determine the way you see the world.
209 The three modes are:
211 - First-person view (default)
212 - Third-person view from behind
213 - Third-person view from the front
215 You can change the camera mode by pressing [F7] (but you have to close this
216 window first).
218 Switch camera mode: [F7]]=]
220 tutorial.texts.blocks =
221 [[The world of Minetest is made entirely out of blocks, or voxels, to be precise.
222 Blocks can be added or removed with the correct tools.
224 In this section, we'll show you a few special but common blocks which behave in unexpected,
225 ways.,
227 Of course, subgames can come up with more special weird blocks.]]
229 tutorial.texts.falling_node =
230 [[Some blocks need to rest on top of another block, otherwise, they fall down.
231 Try it and mine the block below the uppermost block.]]
233 tutorial.texts.attached_node =
234 [[Some blocks have to be attached to another block, otherwise, they drop as an item
235 as if you would have mined it.
237 Attached here is a picture frame. You can't collect or mine it directly, but if you mine
238 the block it is attached to, it will drop as an item which you can collect.]]
240 tutorial.texts.disable_jump =
241 [[These nasty blocks on the floor prevent you from jumping when you stand on them.]]
243 tutorial.texts.runover =
244 [[This abyss behind this sign is so small that you can even walk over it,
245 as long as you don't stop midway. But you can jump over it anyways, just to be,
246 safe.]]
248 tutorial.texts.jumpup =
249 [[You can't reach this upper block by walking. But luckily, you are able to jump.
250 For our purposes, you can jump just high enough to reach one block above you.
251 But you can't two blocks high.
252 Press the space bar once to jump at a constant height.
254 Jump: [Space]
256 Now try it to continue.]]
259 tutorial.texts.jumpover =
260 [=[Here is a slightly larger abyss. Luckily, you can also jump just far enough to
261 cross a gap of this width. Don't worry, the abyss is not deep enough to hurt you
262 when you fall down. There are stairs which lead back up here.
264 Jump: [Space]]=]
266 tutorial.texts.orientation =
267 [[From this point on, there will be branching paths. For orientation, we placed
268 some arrow signs. They just show a short text when you hover them, that's all.
270 You don't have to follow the sections in any particular order, with one exception,
271 for which you will be informed.]]
273 tutorial.texts.sneak =
274 [=[Sneaking is a special move. As long as you sneak, you walk slower, but you are
275 guaranteed to not accidentally fall off the edge of a block. This also allows you to
276 "lean over" in a sense.
277 To sneak, keep the sneak key pressed. As soon as you release the sneak key,
278 you walk at normal speed again. Be careful not releasing the sneak key when you
279 are at a ledge, you might fall!
281 Sneak: [Shift]
283 Keep in mind that the [Shift] key is used for a large number of other things in Minetest.
284 Sneaking only works when you are not in a liquid, stand on solid ground and are not at a
285 ladder.
287 You may try out sneaking at this little blocky pyramid.]=]
289 tutorial.texts.sneakjump =
290 [=[You can jump slightly higher if you jump while holding the sneak key.
292 Sneak: [Shift]
293 Jump: [Space]]=]
295 tutorial.texts.hotbar =
296 [[At the bottom of the screen you see 8 squares. This is called the 'hotbar'.
297 The hotbar allows you to quickly access some items from your inventory.
298 In our case, the upper 8 slots in your inventory.
299 You can change the selected item with the mouse wheel, if you have one, or with the
300 number keys.
302 Select previous item in hotbar: [Mouse wheel up]
303 Select next item in hotbar: [Mouse wheel down]
304 Select item #N in hotbar: the key with the number #N
306 The item you've seleted is also the item you wield. This will be important later for
307 tools, mining, building, etc.]]
310 tutorial.texts.eat =
311 [[In this chest you find some comestibles. Comestibles are items which instantly
312 heal you when eaten. This removes the item from your inventory.
313 To eat one, select the comestible in your hotbar, then click the left mouse button.
314 Unlike other items, you cannot punch or attack while holding a comestible. To be able
315 to attack, you have to select something else.
316 Of course, this does not have to be the only way to heal you.
318 Eat comestible: [Left mouse button]
320 Don't forget to take the gold ingot.]]
322 tutorial.texts.chest =
323 [[Treasure chests are a common sight in Minetest. They are actually not built-in
324 into the game.]]
326 tutorial.texts.damageblock =
327 [[Careful! These spikes hurt you when you stand inside, so don't walk into them.
328 Try to walk around and get the gold ingot.
330 They damage you every second you stand in them.
332 This is one of the many ways you can get hurt in Minetest.]]
334 tutorial.texts.ladder =
335 [[This is a ladder. Ladders help you to climb up great heights or to climb down safely.
336 To climb a ladder, go into the block occupied by the ladder and hold one of the
337 following keys:
339 Climb up ladder: [Space]
340 Climb down ladder: [Shift]
342 Note that sneaking and jumping do not work when you are at a ladder.]]
344 tutorial.texts.swim =
345 [[What you see here is a small swimming pool. You are able to swim and dive.
346 Diving usually costs you breath. While diving, 10 bubbles appear in the heads-up display.
347 These bubbles disappear over time while diving and when you are out of bubbles,
348 you slowly lose some health points. You have to back up to the surface from time to
349 time to restore the bubbles.
351 Movement in a liquid is slightly different than on solid ground:
353 Swim forwards: [W]
354 Swim backwards: [S]
355 Swim leftwards: [A]
356 Swim rightwards: [D]
357 Swim upwards: [Space]
358 Swim downwards: [Shift]
360 At the bottom of the pool lies a gold ingot. Try to get it!]]
363 tutorial.texts.dive =
364 [=[To get to the other side, you have to dive here. Don't worry, the tunnel is not
365 long. But don't stay too long in the water, or else you take damage.
366 At the bottom of the pool lies a gold ingot. Try to get it!
368 Swim forwards: [W]
369 Swim backwards: [S]
370 Swim leftwards: [A]
371 Swim rightwards: [D]
372 Swim upwards: [Space]
373 Swim downwards: [Shift]]=]
375 tutorial.texts.waterfall = ""..
376 [=[You can easily swim up this waterfall. Go into the water and hold the space bar until you're
377 at the top
379 Swim forwards: [W]
380 Swim backwards: [S]
381 Swim leftwards: [A]
382 Swim rightwards: [D]
383 Swim upwards: [Space]
384 Swim downwards: [Shift]]=]
386 tutorial.texts.liquidtypes =
387 [=[Liquids behave somewhat weirdly in Minetest. Actually, there are 2 kinds of liquids.
388 If you watched the waterfall closely, you may have noticed that there is a slight difference
389 between the water blocks that make the waterfall, and those up here in the basin.
391 Minetest distinguishes between liquid source and flowing liquid.
393 A liquid source block is always a full cube.
394 A flowing liquid block looks slightly different. Often, it is not a full cube, but has a more or less
395 triangular shape. Also, flowing liquids usually have an unique "flowing" animation, but this may
396 not be the case for all liquids.
398 Up in the basin, you see four rows of liquid sources, followed by one row of flowing
399 liquids, followed by the waterfall itself. The waterfall itself is solely made of flowing liquids.
401 Liquid sources generate flowing liquids around them. Liquid sources can also exist on their own.
402 Flowing liquids are not able to exist on their own. They have to originate from a liquid source.
403 If the liquid source is gone, or the way to one is blocked, the flowing liquid will slowly dry
404 out.
406 To the right of this sign is a special block. When used, it will block the liquid flow.
407 Use that block, being close enough and looking at it, and watch the waterfall dry out.
409 Use something: [Right mouse button]]=]
411 tutorial.texts.viscosity =
412 [[Minetest mods can introduce various liquids which differ in their properties.
413 Probably the most important property is their viscosity. Here you have some
414 pools which differ in their viscosity. Feel free to try them out.]]
416 tutorial.texts.pointing1 =
417 [[An important general concept in Minetest is pointing. As mentioned earlier,
418 there is a crosshair in the center of the screen.
420 You can point several things in Minetest:
422 - Blocks
423 - Dropped items
424 - Other players
425 - Many other things
427 You can only point one thing at once, or nothing at all. You can tell when
428 you point something if it is surrounded by a thin cuboid wireframe.
430 To point something, three conditions have to be met:
431 1. The thing in question must be pointable at all
432 2. Your crosshair must be exactly over the thing in question
433 3. You must be close enough to the thing
435 When a thing is pointed, you can do different stuff with it; e.g. collecting it,
436 punching it, building to it, etc. We come to all that later.
438 Now collect that apple from the small tree in front of this sign, and the gold bar.
439 To do that, you must point it and click with the left mouse button.]]
442 tutorial.texts.pointing2 =
443 [[The distance you need to point to things solely depends on the tool you carry.
444 Most tools share a default value but some tools may have a longer or shorter distance.
446 At the moment, your only "tool" is the hand. It was good enough to collect the apple
447 from the small tree.
449 Above this sign hang some apples, but you cannot reach them by normal means. At the
450 wall in front of this sign lies a special example tool which you can use to retrieve the apple
451 from afar.
453 To take the tool, point to it and click the left mouse button. Then select it with the
454 mouse wheel or the number keys. You will learn more about tools in a different section.]]
456 tutorial.texts.health =
457 [[Unless you have damage disabled, all players start with 20 hit points (HP), represented
458 by ten hearts in the heads-up display. One HP is represented by half a heart in this
459 tutorial, but the actual representation can vary from subgame to subgame.
461 You can take damage for the following reasons (including, but not limited to):
462 - Falling too deep
463 - Standing in a block which hurts you
464 - Attacks from other players
465 - Staying too long in a liquid
467 In this tutorial, you can regain health by eating a comestible. This is only an example,
468 mods and subgames may come with other mechanisms to heal you.
470 When you lose all your hit points, you die. Death is normally not really that bad in Minetest.
471 When you die, you will usually lose all your possessions. You are able to put yourself
472 into the world immediately again. This is called "respawning". Normally you appear at a
473 more or less random location.
474 In the tutorial you can die, too, but don't worry about that. You will
475 respawn at a special location you can't normally reach and keep all your posessions.
476 Subgames may introduce special events on a player's death.]]
478 tutorial.texts.death =
479 [[Oops! So it seems you just have died. Don't worry, you don't have lost any of your
480 possessions and you have been revived. You are still in Tutorial World at a different
481 location.
483 You have arrived at the so-called respawn location of Tutorial World. You will
484 always appear here after you died. This is called "respawning". In most worlds,
485 however, you will respawn in a slightly randomized location.
487 The tutorial uses a so-called fixed spawn point, so you respawn always at the same
488 spot. This is unusual for singleplayer worlds, but in online play, some servers
489 use fixed spawn points, too.
491 Under normal conditions you would have lost all or a part of your possessions or some
492 other bad thing would have happened to you. But not here, this is a tutorial.
494 To continue, just drop out at the end of that gangway. The drop is safe.]]
499 tutorial.texts.items =
500 [[Throughout your journey, you will probably collect many items. Once you collected
501 them, blocks are considered to be items, too.
503 Items can be stored in your inventory and selected with the hotbar (see the other signs).
504 You can wield any items; you can even punch with almost any item to hurt enemies.
505 Usually, you will deal a minimal default damage with most items. Even if you do not hold,
506 an item at all.
507 If you don't want to have an item anymore, you can always throw it away. Likewise,
508 you can collect items which lie around by pointing and leftclicking them.
510 Collect item: [Left mouse button]
511 Drop carried item stack: [Q]
512 Drop single item from carried item stack: [Shift] + [Q]
514 On the table at the right to this sign lies an item stack of 50 rocks so you have some items,
515 to test out the inventory.]]
517 tutorial.texts.tools =
518 [[A tool is a special kind of item.
519 Tools can be used for many things, such as:
520 - Breaking blocks
521 - Collecting liquids
522 - Rotating blocks
523 - Many others!
524 The number of tools which are possible in Minetest is innumberable and are
525 too many to cover in this tutorial.
526 But at least we will look at a very common and important tool type: mining tools,
527 We will come to that in the mining section.
529 Many tools wear off and get destroyed after you used them for a while. In an
530 inventory the tool's "health" is indicated by a colored bar
532 Tools may be able to be repaired, see the sign about repairing.]]
534 tutorial.texts.inventory =
535 [[The inventory menu usually contains the player inventory. This allows you
536 to carry along items throughout the world.
538 Every inventory is made out of slots where you can store items in. You can store one
539 entire stack of items per slot, the only condition is that the items are of the same
540 type. In this tutorial all items except for tools stack up to 99 items, but this number
541 can vary in actual subgames.
543 Here are the controls which explain how to move around the items within the inventory:
545 In the game:
546 Open inventory menu: [I]
548 When the inventory is opened and you don't hold any items:
549 Take item stack: [Left mouse button]
550 Take 10 items from item stack: [Middle mouse button]
551 Take half item stack: [Right mouse button]
553 When you took an item stack in the inventory:
554 Put item stack: [Left mouse button]
555 Put 10 items from item stack: [Middle mouse button]
556 Put single item from item stack: [Right mouse button]
558 You can also drop an item stack by holding it in the inventory, then clicking anywhere
559 outside of the window.]]
561 tutorial.texts.chest =
562 [[This is a chest. You can view its contents by right-clicking it. In the menu you will see
563 two inventories, on the upper part the chest inventory and on the lower part the player
564 inventory. Exchanging items works exactly the same as in the inventory menu.]]
567 tutorial.texts.build =
568 [[Another important task in Minetest is building blocks.
569 "Building" here refers to the task of placing one block in your possession onto
570 another block in the world.
571 Unlike mining, building a block happens instantanous. To build, select a block in your
572 hotbar, point to any block in the world and press the right mouse button.
573 Your block will be immediately placed on the pointed side.
574 It is important that the block you want to build to is pointable. This means you cannot build
575 next to or on liquids by normal means.
577 Build on ordinary block: [Right mouse button]
579 Try to get up to that little hole by using the wood blocks in the chest. There is another
580 gold ingot waiting for you.]]
582 tutorial.texts.mine =
583 [[Mining is a method to remove a single block with a mining tool. It is a very important
584 task in Minetest which you will use often.
586 (It is recommended that you go to the crafting and items house first. It is right in front of
587 this sign.)
589 To be able to mine a block, you need
591 1. to have minable block, after all,
592 2. to point on the block and
593 3. to carry an appropriate tool.
595 Mine: [Left mouse button]
597 When you are ready, hold the left mouse button while pointing the block. Depending on
598 the block type and the tool properties, this can take some time. Some tools are fast with
599 some particular block types, some other tools may be slower to mine other block types.
600 If you do not carry an appropriate tool, you are not able to mine the block at all.
601 You can tell that you are actually mining when you see cracks or some other animation
602 on the block in question.
604 When done mining, blocks will often add one or more items to your inventory. This is called
605 the "drop" of a block and depends on the block type. Now try to mine those large cubes in
606 this area, using different tools. Note that all blocks here are just examples to show you
607 different kinds of drops.]]
609 tutorial.texts.mine_cobble =
610 [[This is cobblestone. You can mine it with a pickaxe.
611 This cobblestone will always drop itself, that means, cobblestone. Dropping itself is the
612 usual dropping behaviour of a block, throughout many subgames.]]
614 tutorial.texts.mine_wood =
615 [[These are wooden planks. In the tutorial, you can only mine those blocks with an axe.
616 Wooden planks drop themselves.
618 In Minetest, we use the term "mining" in a general sense, regardless of the material.]]
620 tutorial.texts.mine_conglomerate =
621 [[This is a cube of conglomerate. You need a pickaxe to mine it.
622 Conglomerate drops something based on probability. Conglomerate randomly drops between 1
623 and 5 rocks, when mined.]]
625 tutorial.texts.mine_glass =
626 [[This is some weak glass. You can break it with your bare hands. Or you can use your pickaxe,
627 which is faster. Note that it looks slightly different than the other glass in this world.
628 These glass blocks don't drop anything.]]
630 tutorial.texts.mine_stone =
631 [[This is stone. You need a pickaxe to mine it. When mined, stone will drop cobblestone.]]
633 tutorial.texts.mine_immortal =
634 [[There can always be some blocks which are not minable by any tool. In our tutorial, all
635 those castle walls can't me mined, for example.]]
637 tutorial.texts.craft1 =
638 [[Crafting is the task of taking several items and combining them to form a new item.
639 Crafting is another important task in Minetest.
641 To craft something, you need a few items and a so-called crafting grid.
643 In this tutorial, you have a grid of size 3 times 3 in your inventory.
644 Let's get right into crafting:
646 1. Take 3 sheets of paper from the chest next to this sign.
647 2. Open the inventory menu with [I].
648 3. Place the paper in the crafting grid so that they form a 1×3 vertical line.
649 4. A book should appear in the output slot. Click on it to take it,
650 then put it in your player inventory.
652 This process consumes the paper.
653 When you have the book in your inventory, go on with the next sign.]]
655 tutorial.texts.craft2 =
656 [[To craft the book you have used a so-called crafting recipe. You must know the crafting
657 recipes as well so you can craft.
659 The crafting recipe you used in particular is a so-called shaped recipe. This means the
660 pattern you place in the crafting grid matters, but you can move the entire pattern
661 freely.
663 There is another kind of crafting recipe: Shapeless.
664 Shapeless recipes only care about which items you place in the crafting grid, but not in
665 which pattern. In the next chest you find some wheat. Let's make dough from it! For this,
666 you have to place at least 1 wheat in 4 different slots, but the other slots must be empty.
667 What is special about this recipe is that you can place them anywhere in the grid.
669 When you got your dough, go on with the next sign.]]
671 tutorial.texts.craft3 =
672 [[Do you got your dough? Good.
674 You may have noticed that crafting always consumes one item from each occupied slot
675 of the crafting grid. This is true for all crafting recipes.
676 You can speed crafting up a bit when you click with the middle mouse button on the
677 item in the output slot. Doing so will attempt to do the same craft up to 10 times,
678 instead of just once.
680 Feel free to try it with the remaining wheat or just go on with the next sign.]]
682 tutorial.texts.craft4 =
683 [[Another important thing to know about crafting are so-called groups. Crafting recipes do
684 not always require you to use the exactly same items every time.
685 This tutorial has a special recipe for books. In the chest, you will find paper in 4
686 different colors. You can also make a book by placing 3 paper sheets of any color
687 in a vertical line.
688 The paper color does not matter here, you can use only white paper, only orange paper
689 or even mix it. What is important here are the occupied slots.
690 This is possible because all 4 types of (example) paper belong to the same group and
691 our book recipe accepts not only white paper, but any paper of that group.
693 Feel free to experiment a bit around with this.]]
695 tutorial.texts.smelt =
696 [[This is a furnace. Furnaces can be used to turn a smeltable item with help of a fuel
697 to a new item. Many items can be furnace fuels, but not all. A few items are smeltable.
699 In order to operate a furnace, you have to put the smeltable item into the 'Source' slot
700 and the fuel into the 'Fuel' slot.
701 As soon as the items have been placed, the furnace automatically starts to smelt the
702 items. The furnace becomes active and consumes an item in the fuel slot. The flame
703 goes on and will continue burning for a given time. The time depends on the fuel type.
704 Some fuels burn very short, and other burn longer. In the furnace menu, the burn time
705 is indicated by the flame symbol. As soon as the flame goes out, the furnace may
706 continue burning if there is still fuel and smeltable material in the furnace,
707 otherwise, the furnace becomes inactive again.
708 The smeltable material has to be exposed to the flame for a given time as well. This
709 time depends on the type of the material, too. Some material smelt faster than others.
710 You can see the smelting progress of a single item on the progress arrow. If one item
711 has been smelt, the result goes to one of the output slots, where you can take it.
713 In the left chest you find some fuels and in the right chest you find some materials to
714 smelt. Feel free to experiment with the furnace a bit. Smelt the gold lump to receive
715 this station's gold bar.
717 Again, this furnace is just an example; the exact operation may differ slightly from
718 subgame to subgame.]]
720 tutorial.texts.repair =
721 [[Some subgames may come with a special recipe which allows you to repair your tools.
722 In those, repairing works always the same way:
723 Place two more or less worn out tools of the same kind into the crafting crid and
724 take the result. The result is a new tool which is slightly repaired by a fixed percentage.
726 Of course, this tutorial comes with such a recipe. The chest next to this sign stores
727 some damaged tools which you may try to repair now.]]
730 tutorial.texts.use =
731 [=[You will often meet some blocks you can use. Something special happens when you
732 right-click while pointing on them.
733 In fact, you already used such blocks: All the signs you read are "usable" blocks.
735 There is a strange device next to this sign. Use it and see what happens.
737 Use usable block: [Right mouse button]]=]
740 tutorial.texts.basic_end =
741 [[If you think you have enough of this tutorial, you can leave at any time. There are
742 13 gold ingots at the stations to be found, to help you keep track.
744 You can find the gold ingots at the following stations:
745 - Ladders
746 - Sneaking
747 - Swimming
748 - Diving
749 - Waterfall
750 - Viscosity
751 - Comestibles and Eating
752 - Pointing
753 - Crafting
754 - Smelting
755 - Mining
756 - Building
757 - Damage and Health
759 If you've got 13 gold ingots (in total), you probably know now everything which can be
760 learned from this tutorial. Collecting the gold ingots is optional.
762 After you closed this dialog, you can press [Esc] to open the pause menu and return
763 to the main menu or quit Minetest.
765 In the next room there are some further signs with information, but it is entirely optional
766 and not related to gameplay.]]
768 tutorial.texts.fallout =
769 [[You somehow managed to fall from the castle or got otherwise below it!
770 How did you do that?
772 Anyways, you've got teleported back to the starting location. Whatever you did, be more
773 careful next time.]]
775 tutorial.texts.first_gold =
776 [[You have collected your first gold ingot. Those will help you to keep track in this tutorial.
777 There are 14 gold ingots in this tutorial.
779 There is a gold ingot at every important station. If you collected all ingots, you are
780 done with the tutorial, but collecting the gold ingots is not mandatory.]]
782 tutorial.texts.last_gold =
783 [[You have collected all the gold ingots in this tutorial.
785 This means you have now travelled to each station. If you read and understood everything,
786 you have learned everything which can be learned from this tutorial.
788 If this is the case, you are finished with this tutorial and can leave now. But feel
789 free to stay in this world to explore the area a bit further.
791 You may also want to visit the Good-Bye room, which has a few more informational
792 signs with supplemental information, but nothing of is is essential or gameplay-relevant.
794 If you want to stay, you leave later by pressing [Esc] to open the pause menu and then
795 return to the main menu or quit Minetest.]]
797 tutorial.texts.first_diamond =
798 [[Great, you have found and collected a hidden diamond! In Tutorial World, there are 12 hidden
799 diamonds. Can you find them all? The first diamond may have been easy to collect, but the
800 remaining 11 diamonds probably won't be that easy.
802 If you manage to find them all, you will be awarded a symbolic prize.]]
804 tutorial.texts.last_diamond =
805 [[Congratulations!
806 You have collected all the diamonds of Tutorial World!
808 To recognize this achievement, you have been awarded with a diamond cup. It has been placed in
809 the Good-Bye Room for you.]]
812 tutorial.texts.controls =
813 [[To recap, here is an overview over the most important default controls:
815 Move forwards: [W]
816 Move left: [A]
817 Move backwards: [S]
818 Move right: [D]
819 Jump: [Space]
820 Sneak: [Shift]
821 Move upwards (ladder/liquid): [Space]
822 Move downwards (ladder/liquid): [Shift]
824 Toggle camera mode: [F7]
826 Select item in hotbar: [Mouse wheel]
827 Select item in hotbar: [0] - [9]
828 Inventory menu: [I]
830 Collect pointed item: [Left mouse button]
831 Drop item stack: [Q]
832 Drop single item: [Shift] + [Q]
834 Punch: [Left mouse button]
835 Mine: [Left mouse button]
836 Build/use: [Right mouse button]
837 Build: [Shift] + [Right mouse button]
839 Abort/open pause menu: [Esc]
841 You can review a shorter version of the controls in the pause menu.]]
844 tutorial.texts.online =
845 [[You may want to check out these online resources related to Minetest:
847 Official homepage of Minetest: <http://minetest.net/>
848 The main place to find the most recent version of Minetest.
850 Community wiki: <http://wiki.minetest.net/>
851 A community-based documentation website for Minetest. Anyone with an account can edit
852 it! It also features a documentation of the default game, which was NOT covered by
853 this tutorial.
855 Webforums: <http://forums.minetest.net/>
856 A web-based discussion platform where you can discuss everything related to Minetest.
857 This is also a place where player-made mods and subgames are published and
858 discussed. The discussions are mainly in English, but there is also space for
859 discussion in other languages.
861 Chat: <irc://irc.freenode.net#minetest>
862 A generic Internet Relay Chat channel for everything related to Minetest where people can
863 meet to discuss in real-time.
864 If you do not understand IRC, see the Community Wiki for help.]]
867 tutorial.register_infosign("intro", "Introduction", tutorial.texts.intro)
868 tutorial.register_infosign("minetest", "Minetest", tutorial.texts.minetest)
869 tutorial.register_infosign("cam", "Player Camera", tutorial.texts.cam)
870 tutorial.register_infosign("runover", "Small Abysses", tutorial.texts.runover)
871 tutorial.register_infosign("jumpup", "Jumping (1)", tutorial.texts.jumpup)
872 tutorial.register_infosign("jumpover", "Jumping (2)", tutorial.texts.jumpover)
873 tutorial.register_infosign("sneak", "Sneaking", tutorial.texts.sneak)
874 tutorial.register_infosign("sneakjump", "Sneak-jumping", tutorial.texts.sneakjump)
875 tutorial.register_infosign("orientation", "Information about the following tutorial sections", tutorial.texts.orientation)
876 tutorial.register_infosign("hotbar", "Hotbar", tutorial.texts.hotbar)
877 tutorial.register_infosign("eat", "Comestibles and Eating", tutorial.texts.eat)
878 tutorial.register_infosign("chest", "Chests", tutorial.texts.chest)
879 tutorial.register_infosign("damageblock", "Blocks Which Hurt You", tutorial.texts.damageblock)
880 tutorial.register_infosign("ladder", "Climbing Ladders", tutorial.texts.ladder)
881 tutorial.register_infosign("swim", "Swimming", tutorial.texts.swim)
882 tutorial.register_infosign("dive", "Diving", tutorial.texts.dive)
883 tutorial.register_infosign("waterfall", "Swimming up a Waterfall", tutorial.texts.waterfall)
884 tutorial.register_infosign("viscosity", "Viscosity", tutorial.texts.viscosity)
885 tutorial.register_infosign("liquidtypes", "Liquid sources and flowing liquids", tutorial.texts.liquidtypes)
886 tutorial.register_infosign("pointing1", "Pointing (1)", tutorial.texts.pointing1)
887 tutorial.register_infosign("pointing2", "Pointing (2)", tutorial.texts.pointing2)
888 tutorial.register_infosign("health", "Health and Damage", tutorial.texts.health)
889 tutorial.register_infosign("death", "Death and Respawning", tutorial.texts.death)
890 tutorial.register_infosign("items", "Items", tutorial.texts.items)
891 tutorial.register_infosign("tools", "Tools", tutorial.texts.tools)
892 tutorial.register_infosign("inventory", "Using the Inventory", tutorial.texts.inventory)
893 tutorial.register_infosign("chest", "Comment About Chests", tutorial.texts.chest)
894 tutorial.register_infosign("build", "Building Some Blocks", tutorial.texts.build)
895 tutorial.register_infosign("mine", "Mining blocks", tutorial.texts.mine)
896 tutorial.register_infosign("mine_cobble", "Mining example: Cobblestone", tutorial.texts.mine_cobble)
897 tutorial.register_infosign("mine_stone", "Mining example: Stone", tutorial.texts.mine_stone)
898 tutorial.register_infosign("mine_conglomerate", "Mining example: Conglomerate", tutorial.texts.mine_conglomerate)
899 tutorial.register_infosign("mine_wood", "Mining example: Wooden Planks", tutorial.texts.mine_wood)
900 tutorial.register_infosign("mine_glass", "Mining example: Weak glass", tutorial.texts.mine_glass)
901 tutorial.register_infosign("mine_immortal", "Unminable blocks", tutorial.texts.mine_immortal)
902 tutorial.register_infosign("blocks", "Special blocks", tutorial.texts.blocks)
903 tutorial.register_infosign("disable_jump", "No-jumping blocks", tutorial.texts.disable_jump)
904 tutorial.register_infosign("falling_node", "Falling blocks", tutorial.texts.falling_node)
905 tutorial.register_infosign("attached_node", "Attached blocks", tutorial.texts.attached_node)
906 tutorial.register_infosign("use", "Using blocks", tutorial.texts.use)
907 tutorial.register_infosign("craft1", "Crafting Basics", tutorial.texts.craft1)
908 tutorial.register_infosign("craft2", "Crafting using Shapeless Recipes", tutorial.texts.craft2)
909 tutorial.register_infosign("craft3", "Crafting Faster", tutorial.texts.craft3)
910 tutorial.register_infosign("craft4", "Crafting Groups", tutorial.texts.craft4)
911 tutorial.register_infosign("smelt", "Furnace Operation Instructions", tutorial.texts.smelt)
912 tutorial.register_infosign("repair", "Repairing Tools", tutorial.texts.repair)
913 tutorial.register_infosign("basic_end", "End of the Basic Tutorial", tutorial.texts.basic_end)
914 tutorial.register_infosign("controls", "Controls Overview", tutorial.texts.controls)
915 tutorial.register_infosign("online", "Online Resources", tutorial.texts.online)
916 tutorial.register_infosign("subgame", "Subgames", tutorial.texts.subgame)
918 minetest.register_node("tutorial:wall", {
919 description = S("reinforced wall"),
920 tiles = {"default_stone_brick.png"},
921 is_ground_content = true,
922 groups = {immortal=1},
923 sounds = default.node_sound_stone_defaults(),
926 minetest.register_node("tutorial:reinforced_glass", {
927 description = S("reinforced glass"),
928 drawtype = "glasslike",
929 tiles = {"tutorial_reinforced_glass.png"},
930 inventory_image = minetest.inventorycube("tutorial_reinforced_glass.png"),
931 paramtype = "light",
932 sunlight_propagates = true,
933 groups = { immortal=1 },
934 sounds = default.node_sound_glass_defaults(),
937 minetest.register_node("tutorial:weak_glass", {
938 description = S("weak glass"),
939 drawtype = "glasslike",
940 tiles = {"tutorial_weak_glass.png"},
941 inventory_image = minetest.inventorycube("tutorial_weak_glass.png"),
942 paramtype = "light",
943 sunlight_propagates = true,
944 groups = { cracky=3, oddly_breakable_by_hand=1 },
945 drop = "",
946 sounds = default.node_sound_glass_defaults(),
950 minetest.register_tool("tutorial:snatcher", {
951 description = S("apple snatcher"),
952 inventory_image = "tutorial_snatcher.png",
953 wield_image = "tutorial_snatcher.png",
954 wield_scale = { x = 1, y = 1, z = 1 },
955 range = 10,
956 tool_capabilities = {},
959 --[[ A special switch which, when flipped, exchanges day for night and vice versa. ]]
960 minetest.register_node("tutorial:day", {
961 description = S("day/night switch (day)"),
962 tiles = { "tutorial_day.png" },
963 groups = {immortal=1},
964 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
965 minetest.set_timeofday(0)
966 minetest.set_node(pos, {name="tutorial:night"})
969 minetest.register_node("tutorial:night", {
970 description = S("day/night switch (night)"),
971 tiles = { "tutorial_night.png" },
972 groups = {immortal=1},
973 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
974 minetest.set_timeofday(0.5)
975 minetest.set_node(pos, {name="tutorial:day"})
979 --[[ A special switch which "activates" and "deactivates" the waterfall in Tutorial World.
980 It only works on a prepared map! ]]
981 minetest.register_node("tutorial:waterfall_on", {
982 description = S("waterfall switch (on)"),
983 tiles = { "tutorial_waterfall_on.png" },
984 groups = {immortal=1},
985 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
986 local wpos = { y = 5, z = 86 }
987 for x=33,46 do
988 wpos.x = x
989 minetest.set_node(wpos, {name="tutorial:wall"})
991 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_off"})
992 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_off"})
995 minetest.register_node("tutorial:waterfall_off", {
996 description = S("waterfall switch (off)"),
997 tiles = { "tutorial_waterfall_off.png" },
998 groups = {immortal=1},
999 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
1000 local wpos = { y = 5, z = 86 }
1001 for x=33,46 do
1002 wpos.x = x
1003 minetest.remove_node(wpos)
1005 minetest.set_node({x=30,y=7,z=91}, {name="tutorial:waterfall_on"})
1006 minetest.set_node({x=40,y=2,z=86}, {name="tutorial:waterfall_on"})
1010 -- Ruler (used in sneaking section)
1011 minetest.register_node("tutorial:ruler", {
1012 description = S("ruler"),
1013 drawtype = "signlike",
1014 selection_box = {
1015 type = "wallmounted",
1016 wall_side = { -0.5, -0.5, 1/16, -0.4, 0.5, 0.5 },
1018 walkable = false,
1019 tiles = { "tutorial_ruler.png" },
1020 inventory_image = "tutorial_ruler.png",
1021 wield_image = "tutorial_ruler.png",
1022 paramtype = "light",
1023 paramtype2 = "wallmounted",
1024 sunlight_propagates = true,
1025 groups = {immortal=1, attached_node=1},
1029 --[[ Tutorial cups, awarded for achievements ]]
1030 tutorial.cupnodebox = {
1031 type = "fixed",
1032 fixed = {
1033 {-0.3,-0.5,-0.3,0.3,-0.4,0.3}, -- stand
1034 {-0.1,-0.4,-0.1,0.1,0,0.1}, -- handle
1035 {-0.3,0,-0.3,0.3,0.1,0.3}, -- cup (lower part)
1036 -- the 4 sides of the upper part
1037 {-0.2,0.1,-0.3,0.2,0.5,-0.2},
1038 {-0.2,0.1,0.2,0.2,0.5,0.3},
1039 {-0.3,0.1,-0.3,-0.2,0.5,0.3},
1040 {0.2,0.1,-0.3,0.3,0.5,0.3},
1044 --[[ awarded for collecting all gold ingots ]]
1045 minetest.register_node("tutorial:cup_gold", {
1046 description = S("golden cup"),
1047 tiles = { "default_gold_block.png" },
1048 paramtype = "light",
1049 drawtype = "nodebox",
1050 node_box = tutorial.cupnodebox,
1051 groups = { immortal = 1 }
1054 --[[ awarded for collecting all diamonds ]]
1055 minetest.register_node("tutorial:cup_diamond", {
1056 description = S("diamond cup"),
1057 tiles = { "default_diamond_block.png" },
1058 paramtype = "light",
1059 drawtype = "nodebox",
1060 node_box = tutorial.cupnodebox,
1061 groups = { immortal = 1 }
1066 --[[ This function shows a simple dialog window with scrollable text
1067 name: name of the player to show the formspec to
1068 caption: Caption of the dialog window (not escaped)
1069 text: The text to be shown. Must be escaped manually for formspec, an unescaped
1070 comma generates a line break.
1072 function tutorial.show_default_dialog(name, caption, text)
1073 local formspec = "size[12,6]"..
1074 "label[-0.15,-0.4;"..minetest.formspec_escape(caption).."]"..
1075 "tablecolumns[text]"..
1076 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1077 "table[0,0.25;12,5.2;text_table;"..
1078 tutorial.convert_newlines(minetest.formspec_escape(S(text)))..
1079 "]"..
1080 "button_exit[4.5,5.5;3,1;close;"..S("Close").."]"
1081 minetest.show_formspec(name, "tutorial_dialog", formspec)
1084 minetest.register_on_joinplayer(function(player)
1085 local formspec = nil
1086 if(minetest.is_singleplayer() == false) then
1087 formspec = "size[12,6]"..
1088 "label[-0.15,-0.4;"..minetest.formspec_escape(S("Warning: You're not playing in singleplayer mode")).."]"..
1089 "tablecolumns[text]"..
1090 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1091 "table[0,0.25;12,5.2;creative_text;"..
1092 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.notsingleplayer)))..
1093 "]"..
1094 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
1095 "button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
1096 elseif(minetest.setting_getbool("creative_mode")) then
1097 formspec = "size[12,6]"..
1098 "label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
1099 "tablecolumns[text]"..
1100 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1101 "table[0,0.25;12,5.2;creative_text;"..
1102 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.creative)))..
1103 "]"..
1104 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
1105 "button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
1107 else
1108 if(tutorial.state.first_join==true) then
1109 formspec = "size[12,6]"..
1110 "label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
1111 "tablecolumns[text]"..
1112 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1113 "table[0,0.25;12,5.2;intro_text;"..
1114 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.intro)))..
1115 "]"..
1116 "button_exit[4.5,5.5;3,1;close;"..minetest.formspec_escape(S("Close")).."]"
1118 tutorial.state.first_join = false
1119 tutorial.save_state()
1121 if(formspec~=nil) then
1122 minetest.show_formspec(player:get_player_name(), "intro", formspec)
1127 minetest.register_on_player_receive_fields(function(player, formname, fields)
1128 if(fields.leave) then
1129 minetest.kick_player(player:get_player_name(), S("You have voluntarily exited the tutorial."))
1131 if(fields.gotostart) then
1132 tutorial.back_to_start(player)
1134 if(fields.gotoend) then
1135 tutorial.go_to_end(player)
1137 end)
1139 tutorial.steptimer = 0
1140 minetest.register_globalstep(function(dtime)
1141 tutorial.steptimer = tutorial.steptimer + dtime
1142 local players = minetest.get_connected_players()
1143 if(tutorial.steptimer > 2) then
1144 for p=1,#players do
1145 local player = players[p]
1146 local name = player:get_player_name()
1147 if(player:getpos().y < -12 and (not minetest.setting_getbool("creative_mode"))) then
1148 -- teleport players back to the start when they fell away
1149 tutorial.back_to_start(player)
1150 tutorial.show_default_dialog(name, S("You fell from the castle!"), tutorial.texts.fallout)
1152 else
1153 local inv = player:get_inventory()
1154 local state_changed = false
1156 if(tutorial.state.first_gold ~= true) then
1157 local gold_stack = ItemStack("default:gold_ingot 1")
1158 if(inv:contains_item("main", gold_stack)) then
1159 tutorial.show_default_dialog(
1160 name,
1161 S("Gold ingots in the tutorial"),
1162 tutorial.texts.first_gold
1164 tutorial.state.first_gold = true
1165 state_changed = true
1168 if(tutorial.state.last_gold ~= true) then
1169 local gold_stack = ItemStack("default:gold_ingot "..tostring(tutorial.gold))
1170 if(inv:contains_item("main", gold_stack)) then
1171 local formspec = "size[12,6]"..
1172 "label[-0.15,-0.4;"..minetest.formspec_escape(S("You've finished the tutorial!")).."]"..
1173 "tablecolumns[text]"..
1174 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1175 "table[0,0.25;12,5.2;creative_text;"..
1176 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.last_gold)))..
1177 "]"..
1178 "button_exit[0.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
1179 "button_exit[4.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"..
1180 "button_exit[8.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
1182 minetest.show_formspec(name, "tutorial_last_gold", formspec)
1184 minetest.set_node({x=19,y=2,z=72}, {name="tutorial:cup_gold"})
1185 tutorial.state.last_gold = true
1186 state_changed = true
1190 if(tutorial.state.first_diamond ~= true) then
1191 local diamond_stack = ItemStack("default:diamond 1")
1192 if(inv:contains_item("main", diamond_stack)) then
1193 tutorial.show_default_dialog(
1194 name,
1195 S("You found a hidden diamond!"),
1196 tutorial.texts.first_diamond
1198 tutorial.state.first_diamond = true
1199 state_changed = true
1202 if(tutorial.state.last_diamond ~= true) then
1203 local diamond_stack = ItemStack("default:diamond "..tostring(tutorial.diamonds))
1204 if(inv:contains_item("main", diamond_stack)) then
1205 local formspec = "size[12,6]"..
1206 "label[-0.15,-0.4;"..minetest.formspec_escape(S("You have collected all hidden diamonds!")).."]"..
1207 "tablecolumns[text]"..
1208 "tableoptions[background=#000000;highlight=#000000;border=false]"..
1209 "table[0,0.25;12,5.2;last_diamond_text;"..
1210 tutorial.convert_newlines(minetest.formspec_escape(S(tutorial.texts.last_diamond)))..
1211 "]"..
1212 "button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue")).."]"..
1213 "button_exit[6.5,5.5;3,1;gotoend;"..minetest.formspec_escape(S("Go to Good-Bye room")).."]"
1214 minetest.show_formspec(name, "tutorial_last_diamond", formspec)
1216 minetest.set_node({x=19,y=2,z=74}, {name="tutorial:cup_diamond"})
1217 tutorial.state.last_diamond = true
1218 state_changed = true
1222 if(state_changed) then
1223 tutorial.save_state()
1227 tutorial.steptimer = 0
1229 end)
1231 function tutorial.back_to_start(player)
1232 player:setpos({x=42,y=0.5,z=28})
1235 function tutorial.go_to_end(player)
1236 player:setpos({x=23,y=0.5,z=74})
1239 --[[
1240 FIXME: This does not work in 0.4.10 thanks to a bug. Uncomment this as soon as
1241 set_physics_override gets fixed
1243 function tutorial.disable_sneak_glitch(player)
1244 player:set_physics_override({sneak_glitch=false, sneak=false})
1247 minetest.register_on_newplayer(tutorial.disable_sneak_glitch)
1248 minetest.register_on_joinplayer(tutorial.disable_sneak_glitch)
1249 minetest.register_on_respawnplayer(tutorial.disable_sneak_glitch)
1253 --[[
1254 Helper tools for sign text extracting
1255 must be called with /lua from luacmd
1256 An ugly, quick and dirty hack.
1257 TODO: Toss away intllib in favor of gettext as soon as possible
1260 function tutorial.convert_newlines_for_intllib(str)
1261 local function convert(s)
1262 return s:gsub("\n", function(slash, what)
1263 return "\\n"
1264 end)
1267 return convert(str)
1270 function tutorial.extract_texts()
1271 local filepath = minetest.get_modpath("tutorial").."/locale/template_texts.txt"
1272 local file = io.open(filepath, "w")
1273 if(file) then
1274 for k,v in pairs(tutorial.texts) do
1275 file:write("# Tutorial text: "..k.."\n")
1276 file:write(tutorial.convert_newlines_for_intllib(v).."\n\n")
1278 else
1279 minetest.log("error", "[tutorial] An attempt to write into "..filepath.." failed.")
1281 io.close(file)