-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.lua
223 lines (179 loc) · 6.12 KB
/
api.lua
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
217
218
219
220
221
222
223
------Story NPC Lua Api------
----------------------------------------------------------------------------
-- -
-- Setup and Utility Functions -
-- -
----------------------------------------------------------------------------
local mesdat = ...
local storage = mesdat.storage
local _context = mesdat._conext
local function get_context(name)
local context = _context[name] or {}
_context[name] = context
return context
end
minetest.register_privilege("npc_master", {
description = "Can edit/make/delete Story NPC's"
})
local function _priv(name)
return minetest.check_player_privs(name, {npc_master = true })
end
---To be defined later, these are for common string getting functions
--Current function ideas:
--Header and footer for formspecs
--Sanitize String functions
--Valid result Functions (returns multiple things, like valid/invalid + error)
--
--
--local filefunction = assert(loadfile("file.lua"))
--local filefuncwithargs = assert(loadfile("funcargs.lua"))(10,20,30) --Note the (10,20,30) can be called later too
--In funcargs.lua: 'local a,b,c =... '
--
-- Utility Functions from util.lua
--
--Edit-style formspec header
local ehead,
--Edit-style formspec footer
efoot,
--Forspec Sanitize Input Function
mksafe,
--Texture List Table (alphabetical, reverse lookup based on texture_name
texture_table,
-- texture_list
texture_list,
--Model List Table (alphabetical, reverse lookup based on texture_name
model_table,
-- model_list
model_list,
--sound List Table (alphabetical, reverse lookup based on texture_name
sound_table,
-- sound_list
sound_list = (assert(loadfile("util.lua"))
----------------------------------------------------------------------------
-- Formspecs -
-- -
-- Hierarchy: Actions->Specific Action Subscreen -
-- / -
-- Main_edit -> Events -> Event -
-- \ -
-- Triggers->Specific Trigger Subscreen -
-- -
-- Each formspec also has all its associated funtion calls -
-- Defined with it so it's easier to modify and understand -
-- We also check all user input for validity when possible. -
-- -
-- Note the function declarations below are required -
-- otherwise each function doesn't know how to call -
-- the right formspec -
----------------------------------------------------------------------------
--
-- Function Declarations
--
local main, events, event, actions, triggers
local aflag, adialog, aquery, ashop, anpc, amove, aitem, aquest, aevent
local tflag, tdialog, titem, tloc, tlos
--
-- Main edit formspec functions
--
local function on_recieve_main()
return true
end
main = function(name, texture_name, model_name, color, bgcolor, sound_nameg, sound_namei)
local text = "Hello World"
local formspec = {
"label[0.375,0.5;", minetest.formspec_escape(text), "]",
"field[1,1;3,1;name;name:;" .. name .. "]",
"label[0,2;
"dropdown[1,2;3,2;texture;" .. texture_list .. ";" .. texture_table[texture_name] .. ";]",
"dropdown[1,4;3,2;model;" .. model_list .. ";" .. model_table[model_name] .. ";]",
"field[1,7;3,1;color;Dialog Color:;" .. color .. "]",
"field[1,8;3,1;color;Dialog BGColor:;" .. bgcolor .. "]",
"dropdown[1,4;3,2;Sound Rand;" .. sound_list .. ";" .. sound_table[sound_nameg] .. ";]",
"dropdown[1,4;3,2;Sound Itract;" .. sound_list .. ";" .. sound_table[sound_namei] .. ";]",
--Movement Type
--Movement edit-box (coordinates)
--Events
--Position (useful for moving an entity)
--Health Type
--Max Health
--Save All Changes
}
return ehead() .. table.concat(formspec, "") .. efoot("main")
end
minetest.register_on_joinplayer(function(ObjectRef, last_login)
ObjectRef:set_inventory_formspec(main())
end)
--
-- Events subscreen
--
--
-- Specific Event Subscreen
--
--
-- Triggers subscreen
--
--
-- Actions subscreen
--
--
-- Action: Flag
--
--
-- Action: Dialog
--
--
-- Action: Query
--
--
-- Action: Shop
--
--
-- Action: Npc
--
--
-- Action: Move
--
--
-- Action: Item
--
--
-- Action: Quest
--
--
-- Action: Event
--
--
-- Trigger: Dialog
--
--
-- Trigger: Item
--
--
-- Trigger: Location
--
--
-- Trigger: Line of Sight
--
--
-- Trigger: Flag
--
----------------------------------------------------------------------------
-- -
-- Functions for the main API registration Function -
-- -
----------------------------------------------------------------------------
--
--
--
----------------------------------------------------------------------------
-- -
-- API Registration Function -
-- -
----------------------------------------------------------------------------
local function Register_NPC(model_filename)
--Register
--Add Main_formspec
--register on_recieve_formspec
--Lots of functionality for on_recieve, each with it's own function to call
return true
end