-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.twee
85 lines (68 loc) · 2.21 KB
/
index.twee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
:: StoryTitle
Simple Inventory 3 - Collectibles
:: StoryData
{
"format": "SugarCube",
"format-version": "2.36.1",
"ifid": "862E1FA6-35C6-4E10-BB86-D720812D1528"
}
:: StoryInit
<<newinv $player>>
<<set $xp to 0>>
<<item "medals" "Mini Medals">>
<<description>>
Mini medals! Collect a certain number to earn rewards!
<</item>>
<<item "shinies" "Shinies">>
<<description>>
Collect shinies to earn bonus XP!
<</item>>
<<item "sword" "Cool Sword">>
<<description>>
A cool sword! A mini medal reward!
<</item>>
<<item "trophy" "Swanky Trophy">>
<<description>>
A neat trophy! A mini medal reward!
<</item>>
<<set setup.medalRewards = new Map([
[3, "sword"],
[5, "trophy"]
])>>
:: Story JavaScript [script]
Config.ui.stowBarInitially = false;
Inventory.events.update.on( function (ev) {
if (ev.delta && ev.delta.medals) {
setup.medalRewards.forEach( function (reward, required) {
if (!ev.inventory.has(reward) && ev.inventory.has("medals", required)) {
ev.inventory.pickup(reward, 1);
UI.alert("You collected " + required + " mini medals and earned a " + reward + "!");
}
});
}
});
Inventory.events.update.on( function (ev) {
if (ev.delta && ev.delta.shinies) {
State.variables.xp += 10;
$("#xp").empty().wiki("<<= $xp || 0>>");
}
});
:: StoryCaption
XP: @@#xp;<<= $xp || 0>>@@
:: StoryMenu
<<link "Inventory">>
<<run Dialog.setup("Inventory", "inventory"); Dialog.wiki(Story.get("Inventory").text); Dialog.open()>>
<</link>>
:: Inventory [nobr]
<<inv $player inspect>>
:: Start
This small recipe shows how you can create some basic collectible items. Collectibles are a great way to reward players for solving puzzles or exploring. This example has two types of collectibles: mini medals and shinies.
When the player picks up a shiny, they gain 10 experience points. \
<<link "Click here to \"find\" a shiny!">>
<<pickup $player "shinies" 1>>
<</link>>
When the player finds a certain amount of mini medals, they will automatically receive a reward! \
<<link "Click here to \"find\" a mini medal!">>
<<pickup $player "medals" 1>>
<</link>>
Check the inventory with the link in the Story Menu on the left.