-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_menu.hug
216 lines (179 loc) · 4.29 KB
/
context_menu.hug
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
!----------------------------------------------------------------------------
! Menu and context-menu management:
!
! Taken from misc.hug from Kent Tessman's Future Boy! Selected Source
! files
property build_menu
global menu_count
routine BuildContextMenu
{
! The _VERSION3 checks make sure we are compiling with a recent compiler
! but we will just assume that we are
!#ifset _VERSION3
local i, last_menu_count, char_count
ClearMenu
! General/location section:
run player.build_menu
run location.build_menu
! if not &location.build_menu
! {
if player not in location
{
if parent(player) is container
AddtoMenu("Get out")
else
AddtoMenu("Get up")
}
if not &location.in_to and player in location
{
if location.in_to
AddtoMenu("Go inside")
}
if not &location.out_to and player in location
{
if location.out_to
AddtoMenu("Leave")
}
! }
if menu_count > last_menu_count
AddtoMenu("-")
last_menu_count = menu_count
! Characters/NPCs section:
! We'll assume that NPCs in our game are talked to with >TALK TO CHARACTER
! If that is not the case, this section needs to be changed
! if use_conversations
! {
for i in location
{
if i is living and i is not hidden and i ~= player ! and
! Future Boy! specific attributes (i is not conversing, unconscious, sleeping, dead)
{
char_count++
}
}
if char_count > 3
{
AddtoMenu("Talk to...")
}
else
{
char_count = 0
for i in location
{
if i is living and i is not hidden and i ~= player ! and
! Future Boy! specific attributes (i is not conversing, unconscious, sleeping, dead)
{
local w
char_count++
! Need to do this since The(), below, may
! hijack current pronouns:
local temp_it_obj, temp_him_obj, temp_her_obj, temp_them_obj
temp_it_obj = it_obj
temp_him_obj = him_obj
temp_her_obj = her_obj
temp_them_obj = them_obj
! addcontext and AddtoMenu-by-extension need to be fed a dictionary entry to work. The following
! lines write "TALK TO <CHARACTER NAME>" to the dictionary table
! This is why we need a MAXDICTEXTEND setting;
! it has to be large enough to hold all the
! characters
!
string(_temp_string, "Talk to ")
text to (_temp_string + 8)
The(i)
text to 0
w = dict(_temp_string, 255)
AddtoMenu(w)
it_obj = temp_it_obj
him_obj = temp_him_obj
her_obj = temp_her_obj
them_obj = temp_them_obj
}
}
}
! }
! Only add this one if there's one obvious character (the speaking character)
! to ask about something:
if char_count = 1 and speaking
AddtoMenu("Ask about...")
for i in location
{
if i is living
run i.build_menu
}
if menu_count > last_menu_count
AddtoMenu("-")
last_menu_count = menu_count
! Objects section:
AddtoMenu("Look")
! Carried items:
local dropflag, invflag
for i in player
{
if i is not hidden
{
dropflag = true
invflag = true
run i.build_menu
}
}
if dropflag
AddtoMenu("Drop...")
if invflag
AddtoMenu("Inventory")
! Items in location:
! Future Boy! media code -
! if (DisplayHasGraphics) or ! and objects_detailed) or
! (not DisplayHasGraphics and children(location) > 1)
! graphics-less version:
if children(location) > 1
{
local takeflag, examineflag
for i in location
{
if i ~= player
{
examineflag = true
}
if i is not living
{
takeflag = true
}
}
if takeflag
AddtoMenu("Take...")
if examineflag
AddtoMenu("Examine...")
}
if takeflag or examineflag
AddtoMenu("-")
! Object-specific actions
for i in location
{
if i is not living
run i.build_menu
}
! Uncommment if the "Menu" part below is uncommented:
! if menu_count > last_menu_count
! AddtoMenu("-")
last_menu_count = menu_count
! Uncomment if your game has a "Menu" command
! AddtoMenu("Menu")
!#endif
}
! Use AddtoMenu instead of simply addcontext in order to increment menu_count
! and ClearMenu to empty the menu:
routine AddtoMenu(a)
{
!#ifset _VERSION3
addcontext a
menu_count++
!#endif
}
routine ClearMenu(a)
{
!#ifset _VERSION3
addcontext 0
menu_count = 0
!#endif
}