-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
148 lines (124 loc) · 3.21 KB
/
test.lua
File metadata and controls
148 lines (124 loc) · 3.21 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
require "luaIf"
room = {};
thing = {};
room.livingroom = luaIf.Room:new{
short = "living room";
desc = [[
The main living space of the house. This large
room extends from the front door to the back.
]];
name = {"living", "room"};
};
thing.couch = luaIf.Thing:new{
short = "couch";
desc = [[
A large brown leather couch.]];
name = {"large", "brown", "leather", "couch"};
fixed=true;
};
room.livingroom:placeIn(thing.couch);
thing.chest = luaIf.Thing:new{
short="chest";
desc = [[
A beige plastic chest with a green lid servs as a cofee table.]];
name = {"beige", "plastic", "chest"};
fixed = true;
openable = true;
before_open = function(self)
if(self.supports == nil or #self.supports > 0) then
io.write([[
You don't want to open the chest and knock all the stuff on the
floor do you?
]]);
else
io.write("You unlatch the top and open the chest.\n");
self.open = true;
luaIf.current.score = luaIf.current.score + 5;
end
return true;
end;
before_close = function(self)
io.write("You close the lid and latch the latches.\n");
self.open = false;
luaIf.current.score = luaIf.current.score - 5;
return true;
end;
alert_put_on = function(self, x)
if(self.open) then
io.write("It falls in.\n");
self:placeIn(x);
return true;
else
io.write("You place ", x.pronoun, " ", x.short,
" on top of the chest.\n");
self:placeOn(x);
return true;
end
end;
};
room.livingroom:placeIn(thing.chest);
thing.pipe = luaIf.Thing:new{
short = "pipe";
desc =[[
A plastic pipe.]];
name = {"plastic", "pipe"};
after_take = function()
luaIf.current.score = luaIf.current.score + 1;
end;
}
thing.chest:placeIn(thing.pipe);
thing.junk = luaIf.Thing:new{
short="junk";
pronoun="some";
desc = [[
Piles of stuff]];
name = {"junk", "piles", "stuff"};
after_take = function()
luaIf.current.score = luaIf.current.score + 1;
end;
};
thing.chest:placeOn(thing.junk);
thing.thinggy = luaIf.Thing:new{
pronoun="a";
short="thinggy";
desc="Some kind of thing, you're not sure what it is.";
name={"unknown", "thinggy"};
};
luaIf.current.inventory:placeIn(thing.thinggy);
------------------------------------------------
room.diningroom = luaIf.Room:new{
north = room.livingroom;
short = "diningroom";
desc = [[
This room might be more acurately named the game room.
]];
};
room.livingroom.south = room.diningroom;
waysToDie = {};
waysToDie[thing.pipe] = [[
You grab the pipe and repeated beat yourself in the head until
you fall unconcious and die.
]];
luaIf.addVerb({"kill self"},
function()
for x in luaIf.visible() do
for k,v in pairs(waysToDie) do
if(k == x) then
io.write(v);
luaIf.current.living = false;
luaIf.current.score = luaIf.current.score + 1;
return true;
end
end
end
print("You beat your head against the wall until you die.");
luaIf.current.living = false;
return true;
end
);
luaIf.current.score = 0;
luaIf.current.maxScore = 7;
luaIf.current.room = room.livingroom;
luaIf.mainloop();
io.write("You scored ", luaIf.current.score,
" out of a possible ", luaIf.current.maxScore, " points\n");