diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LSL.lua | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua new file mode 100644 index 0000000..7557668 --- /dev/null +++ b/LuaSL/src/LSL.lua | |||
@@ -0,0 +1,297 @@ | |||
1 | -- A module of LSL stuffs. | ||
2 | -- TODO - currently there is a constants.lsl file. Move it into here. | ||
3 | -- It contains LSL constants and ll*() functions stubs. | ||
4 | -- The compiler compiles this into a LSL_Scripts structure at startup, | ||
5 | -- then uses that for function and variable lookups, as well as looking up in the current script. | ||
6 | -- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these? | ||
7 | |||
8 | -- Use it like this - | ||
9 | -- local lsl = require 'lsl' | ||
10 | |||
11 | --[[ From http://lua-users.org/wiki/LuaModuleFunctionCritiqued | ||
12 | A related note on C code: The luaL_register [9] function in C is | ||
13 | somewhat analogous to the module function in Lua, so luaL_register | ||
14 | shares similar problems, at least when a non-NULL libname is used. | ||
15 | Furthermore, the luaL_newmetatable/luaL_getmetatable/luaL_checkudata | ||
16 | functions use a C string as a key into the global registry. This poses | ||
17 | some potential for name conflicts--either because the modules were | ||
18 | written by different people or because they are different versions of | ||
19 | the same module loaded simultaneously. To address this, one may instead | ||
20 | use a lightuserdata (pointer to variable of static linkage to ensure | ||
21 | global uniqueness) for this key or store the metatable as an | ||
22 | upvalue--either way is a bit more efficient and less error prone. | ||
23 | ]] | ||
24 | |||
25 | local LSL = {}; | ||
26 | |||
27 | LSL.PI = 3.14159265358979323846264338327950; | ||
28 | LSL.PI_BY_TWO = LSL.PI / 2; -- 1.57079632679489661923132169163975 | ||
29 | LSL.TWO_PI = LSL.PI * 2; -- 6.28318530717958647692528676655900 | ||
30 | LSL.DEG_TO_RAD = LSL.PI / 180.0; -- 0.01745329252 | ||
31 | LSL.RAD_TO_DEG = 180.0 / LSL.PI; -- 57.2957795131 | ||
32 | LSL.SQRT2 = 1.4142135623730950488016887242097; | ||
33 | |||
34 | LSL.CHANGED_INVENTORY = 0x001; | ||
35 | LSL.CHANGED_COLOR = 0x002; | ||
36 | LSL.CHANGED_SHAPE = 0x004; | ||
37 | LSL.CHANGED_SCALE = 0x008; | ||
38 | LSL.CHANGED_TEXTURE = 0x010; | ||
39 | LSL.CHANGED_LINK = 0x020; | ||
40 | LSL.CHANGED_ALLOWED_DROP = 0x040; | ||
41 | LSL.CHANGED_OWNER = 0x080; | ||
42 | LSL.CHANGED_REGION = 0x100; | ||
43 | LSL.CHANGED_TELEPORT = 0x200; | ||
44 | LSL.CHANGED_REGION_START = 0x400; | ||
45 | LSL.CHANGED_MEDIA = 0x800; | ||
46 | |||
47 | LSL.DEBUG_CHANNEL = 2147483647; | ||
48 | LSL.PUBLIC_CHANNEL = 0; | ||
49 | |||
50 | LSL.INVENTORY_ALL = -1; | ||
51 | LSL.INVENTORY_NONE = -1; | ||
52 | LSL.INVENTORY_TEXTURE = 0; | ||
53 | LSL.INVENTORY_SOUND = 1; | ||
54 | LSL.INVENTORY_LANDMARK = 3; | ||
55 | LSL.INVENTORY_CLOTHING = 5; | ||
56 | LSL.INVENTORY_OBJECT = 6; | ||
57 | LSL.INVENTORY_NOTECARD = 7; | ||
58 | LSL.INVENTORY_SCRIPT = 10; | ||
59 | LSL.INVENTORY_BODYPART = 13; | ||
60 | LSL.INVENTORY_ANIMATION = 20; | ||
61 | LSL.INVENTORY_GESTURE = 21; | ||
62 | |||
63 | LSL.ALL_SIDES = -1; | ||
64 | LSL.LINK_SET = -1; | ||
65 | LSL.LINK_ROOT = 1; | ||
66 | LSL.LINK_ALL_OTHERS = -2; | ||
67 | LSL.LINK_ALL_CHILDREN = -3; | ||
68 | LSL.LINK_THIS = -4; | ||
69 | |||
70 | LSL.PERM_ALL = 0x7FFFFFFF; | ||
71 | LSL.PERM_COPY = 0x00008000; | ||
72 | LSL.PERM_MODIFY = 0x00004000; | ||
73 | LSL.PERM_MOVE = 0x00080000; | ||
74 | LSL.PERM_TRANSFER = 0x00002000; | ||
75 | LSL.MASK_BASE = 0; | ||
76 | LSL.MASK_OWNER = 1; | ||
77 | LSL.MASK_GROUP = 2; | ||
78 | LSL.MASK_EVERYONE = 3; | ||
79 | LSL.MASK_NEXT = 4; | ||
80 | LSL.PERMISSION_DEBIT = 0x0002; | ||
81 | LSL.PERMISSION_TAKE_CONTROLS = 0x0004; | ||
82 | LSL.PERMISSION_TRIGGER_ANIMATION = 0x0010; | ||
83 | LSL.PERMISSION_ATTACH = 0x0020; | ||
84 | LSL.PERMISSION_CHANGE_LINKS = 0x0080; | ||
85 | LSL.PERMISSION_TRACK_CAMERA = 0x0400; | ||
86 | LSL.PERMISSION_CONTRAL_CAMERA = 0x0800; | ||
87 | |||
88 | LSL.AGENT = 0x01; | ||
89 | LSL.ACTIVE = 0x02; | ||
90 | LSL.PASSIVE = 0x04; | ||
91 | LSL.SCRIPTED = 0x08; | ||
92 | |||
93 | LSL.OBJECT_UNKNOWN_DETAIL = -1; | ||
94 | |||
95 | LSL.PRIM_BUMP_SHINY = 19; | ||
96 | LSL.PRIM_COLOR = 18; | ||
97 | LSL.PRIM_FLEXIBLE = 21; | ||
98 | LSL.PRIM_FULLBRIGHT = 20; | ||
99 | LSL.PRIM_GLOW = 25; | ||
100 | LSL.PRIM_MATERIAL = 2; | ||
101 | LSL.PRIM_PHANTOM = 5; | ||
102 | LSL.PRIM_PHYSICS = 3; | ||
103 | LSL.PRIM_POINT_LIGHT = 23; | ||
104 | LSL.PRIM_POSITION = 6; | ||
105 | LSL.PRIM_ROTATION = 8; | ||
106 | LSL.PRIM_SIZE = 7; | ||
107 | LSL.PRIM_TEMP_ON_REZ = 4; | ||
108 | LSL.PRIM_TYPE = 9; | ||
109 | LSL.PRIM_TYPE_OLD = 1; | ||
110 | LSL.PRIM_TEXGEN = 22; | ||
111 | LSL.PRIM_TEXTURE = 17; | ||
112 | LSL.PRIM_TEXT = 26; | ||
113 | |||
114 | LSL.PRIM_BUMP_NONE = 0; | ||
115 | LSL.PRIM_BUMP_BRIGHT = 1; | ||
116 | LSL.PRIM_BUMP_DARK = 2; | ||
117 | LSL.PRIM_BUMP_WOOD = 3; | ||
118 | LSL.PRIM_BUMP_BARK = 4; | ||
119 | LSL.PRIM_BUMP_BRICKS = 5; | ||
120 | LSL.PRIM_BUMP_CHECKER = 6; | ||
121 | LSL.PRIM_BUMP_CONCRETE = 7; | ||
122 | LSL.PRIM_BUMP_TILE = 8; | ||
123 | LSL.PRIM_BUMP_STONE = 9; | ||
124 | LSL.PRIM_BUMP_DISKS = 10; | ||
125 | LSL.PRIM_BUMP_GRAVEL = 11; | ||
126 | LSL.PRIM_BUMP_BLOBS = 12; | ||
127 | LSL.PRIM_BUMP_SIDING = 13; | ||
128 | LSL.PRIM_BUMP_LARGETILE = 14; | ||
129 | LSL.PRIM_BUMP_STUCCO = 15; | ||
130 | LSL.PRIM_BUMP_SUCTION = 16; | ||
131 | LSL.PRIM_BUMP_WEAVE = 17; | ||
132 | |||
133 | LSL.PRIM_HOLE_DEFAULT = 0; | ||
134 | LSL.PRIM_HOLE_CIRCLE = 16; | ||
135 | LSL.PRIM_HOLE_SQUARE = 32; | ||
136 | LSL.PRIM_HOLE_TRIANGLE = 48; | ||
137 | |||
138 | LSL.PRIM_MATERIAL_STONE = 0; | ||
139 | LSL.PRIM_MATERIAL_METAL = 1; | ||
140 | LSL.PRIM_MATERIAL_GLASS = 2; | ||
141 | LSL.PRIM_MATERIAL_WOOD = 3; | ||
142 | LSL.PRIM_MATERIAL_FLESH = 4; | ||
143 | LSL.PRIM_MATERIAL_PLASTIC = 5; | ||
144 | LSL.PRIM_MATERIAL_RUBBER = 6; | ||
145 | LSL.PRIM_MATERIAL_LIGHT = 7; | ||
146 | |||
147 | LSL.PRIM_SCULPT_TYPE_SPHERE = 1; | ||
148 | LSL.PRIM_SCULPT_TYPE_TORUS = 2; | ||
149 | LSL.PRIM_SCULPT_TYPE_PLANE = 3; | ||
150 | LSL.PRIM_SCULPT_TYPE_CYLINDER = 4; | ||
151 | LSL.PRIM_SCULPT_TYPE_MESH = 5; | ||
152 | LSL.PRIM_SCULPT_TYPE_MIMESH = 6; | ||
153 | |||
154 | LSL.PRIM_SHINY_NONE = 0; | ||
155 | LSL.PRIM_SHINY_LOW = 1; | ||
156 | LSL.PRIM_SHINY_MEDIUM = 2; | ||
157 | LSL.PRIM_SHINY_HIGH = 3; | ||
158 | |||
159 | LSL.PRIM_TYPE_BOX = 0; | ||
160 | LSL.PRIM_TYPE_CYLINDER = 1; | ||
161 | LSL.PRIM_TYPE_PRISM = 2; | ||
162 | LSL.PRIM_TYPE_SPHERE = 3; | ||
163 | LSL.PRIM_TYPE_TORUS = 4; | ||
164 | LSL.PRIM_TYPE_TUBE = 5; | ||
165 | LSL.PRIM_TYPE_RING = 6; | ||
166 | LSL.PRIM_TYPE_SCULPT = 7; | ||
167 | |||
168 | LSL.STRING_TRIM = 3; | ||
169 | LSL.STRING_TRIM_HEAD = 1; | ||
170 | LSL.STRING_TRIM_TAIL = 2; | ||
171 | |||
172 | LSL.TRUE = 1; | ||
173 | LSL.FALSE = 0; | ||
174 | |||
175 | LSL.TYPE_INTEGER = 1; | ||
176 | LSL.TYPE_FLOAT = 2; | ||
177 | LSL.TYPE_STRING = 3; | ||
178 | LSL.TYPE_KEY = 4; | ||
179 | LSL.TYPE_VECTOR = 5; | ||
180 | LSL.TYPE_ROTATION = 6; | ||
181 | LSL.TYPE_INVALID = 0; | ||
182 | |||
183 | LSL.NULL_KEY = "00000000-0000-0000-0000-000000000000"; | ||
184 | LSL.EOF = "\n\n\n"; | ||
185 | |||
186 | LSL.ZERO_ROTATION = {0.0, 0.0, 0.0, 1.0}; | ||
187 | LSL.ZERO_VECTOR = {0.0, 0.0, 0.0}; | ||
188 | |||
189 | -- TODO - Temporary dummy variables to got vector and rotation thingies to work for now. | ||
190 | |||
191 | LSL.s = 1.0; | ||
192 | LSL.x = 0.0; | ||
193 | LSL.y = 0.0; | ||
194 | LSL.z = 0.0; | ||
195 | |||
196 | -- Functions. | ||
197 | |||
198 | function --[[float]] LSL.llPow(--[[float]] number,--[[float]] places) return 0.0 end; | ||
199 | function --[[float]] LSL.llFrand(--[[float]] max) return 0.0 end; | ||
200 | function --[[integer]] LSL.llRound(--[[float]] number) return 0 end; | ||
201 | |||
202 | function --[[key]] LSL.llDetectedKey(--[[integer]] index) return LSL.NULL_KEY end; | ||
203 | function --[[key]] LSL.llDetectedGroup(--[[integer]] index) return LSL.NULL_KEY end; | ||
204 | function --[[integer]] LSL.llSameGroup(--[[key]] avatar) return 0 end; | ||
205 | |||
206 | function --[[float]] LSL.llGetAlpha(--[[integer]] side) return 0.0 end; | ||
207 | function LSL.llSetAlpha(--[[float]] alpha,--[[integer]] side) end; | ||
208 | function LSL.llSetColor(--[[vector]] colour,--[[integer]] side) end; | ||
209 | function LSL.llSetPrimitiveParams(--[[list]] params) end; | ||
210 | function LSL.llSetScale(--[[vector]] scale) end; | ||
211 | function LSL.llSetSitText(--[[string]] text) end; | ||
212 | function LSL.llSetText(--[[string]] text, --[[vector]] colour,--[[float]] alpha) end; | ||
213 | function LSL.llSitTarget(--[[vector]] pos, --[[rotation]] rot) end; | ||
214 | |||
215 | function --[[integer]] LSL.llGetLinkNumber() return 0 end; | ||
216 | function --[[string]] LSL.llGetObjectDesc() return "" end; | ||
217 | function LSL.llSetObjectDesc(--[[string]] text) end; | ||
218 | function --[[string]] LSL.llGetObjectName() return "" end; | ||
219 | function LSL.llSetObjectName(--[[string]] text) end; | ||
220 | |||
221 | function --[[string]] LSL.llGetInventoryName(--[[integer]] tyPe,--[[integer]] index) return "" end; | ||
222 | function --[[integer]] LSL.llGetInventoryNumber(--[[integer]] tyPe) return 0 end; | ||
223 | function --[[integer]] LSL.llGetInventoryType(--[[string]] name) return 0 end; | ||
224 | function --[[key]] LSL.llGetNotecardLine(--[[string]] name,--[[integer]] index) return LSL.NULL_KEY end; | ||
225 | |||
226 | function LSL.llDie() end; | ||
227 | function --[[integer]] LSL.llGetFreeMemory() return 0 end; | ||
228 | function --[[string]] LSL.llGetScriptName() return "" end; | ||
229 | function --[[float]] LSL.llGetTime() return 0.0 end; | ||
230 | function LSL.llResetOtherScript(--[[string]] name) end; | ||
231 | function LSL.llResetScript() end; | ||
232 | function LSL.llResetTime() end; | ||
233 | function LSL.llSetScriptState(--[[string]] name,--[[integer]] running) end; | ||
234 | function LSL.llSetTimerEvent(--[[float]] seconds) end; | ||
235 | function LSL.llSleep(--[[float]] seconds) end; | ||
236 | |||
237 | function LSL.llPlaySound(--[[string]] name,--[[float]] volume) end; | ||
238 | function LSL.llRezObject(--[[string]] name, --[[vector]] position, --[[vector]] velocity, --[[rotation]] rot,--[[integer]] channel) end; | ||
239 | function LSL.llRezAtRoot(--[[string]] name, --[[vector]] position, --[[vector]] velocity, --[[rotation]] rot,--[[integer]] channel) end; | ||
240 | |||
241 | function --[[vector]] LSL.llGetPos() return LSL.ZERO_VECTOR end; | ||
242 | function LSL.llSetPos(--[[vector]] pos) end; | ||
243 | function --[[rotation]] LSL.llGetRot() return LSL.ZERO_ROTATION end; | ||
244 | function LSL.llSetRot(--[[rotation]] rot) end; | ||
245 | |||
246 | function --[[rotation]] LSL.llEuler2Rot(--[[vector]] vec) return LSL.ZERO_ROTATION end; | ||
247 | function --[[vector]] LSL.llRot2Euler(--[[rotation]] rot) return LSL.ZERO_VECTOR end; | ||
248 | |||
249 | function --[[string]] LSL.llGetSubString(--[[string]] text,--[[integer]] start,--[[integer]] eNd) return "" end; | ||
250 | function --[[integer]] LSL.llStringLength(--[[string]] text) return 0 end; | ||
251 | function --[[string]] LSL.llStringTrim(--[[string]] text,--[[integer]] tyPe) return "" end; | ||
252 | function --[[integer]] LSL.llSubStringIndex(--[[string]] text, --[[string]] sub) return 0 end; | ||
253 | function --[[list]] LSL.llParseString2List(--[[string]] In, --[[list]] l, --[[list]] l1) return {} end; | ||
254 | function --[[list]] LSL.llParseStringKeepNulls(--[[string]] In, --[[list]] l, --[[list]] l1) return {} end; | ||
255 | |||
256 | function --[[list]] LSL.llCSV2List(--[[string]] text) return {} end; | ||
257 | function --[[list]] LSL.llDeleteSubList(--[[list]] l,--[[integer]] start,--[[integer]] eNd) return {} end; | ||
258 | function --[[string]] LSL.llDumpList2String(--[[list]] l, --[[string]] separator) return "" end; | ||
259 | function --[[string]] LSL.llList2CSV(--[[list]] l) return "" end; | ||
260 | function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) return 0.0 end; | ||
261 | function --[[integer]] LSL.llList2Integer(--[[list]] l,--[[integer]] index) return 0 end; | ||
262 | function --[[key]] LSL.llList2Key(--[[list]] l,--[[integer]] index) return LSL.NULL_KEY end; | ||
263 | function --[[list]] LSL.llList2List(--[[list]] l,--[[integer]] start,--[[integer]] eNd) return {} end; | ||
264 | function --[[string]] LSL.llList2String(--[[list]] l,--[[integer]] index) return "" end; | ||
265 | function --[[rotation]] LSL.llList2Rotation(--[[list]] l,--[[integer]] index) return LSL.ZERO_ROTATION end; | ||
266 | function --[[vector]] LSL.llList2Vector(--[[list]] l,--[[integer]] index) return LSL.ZERO_VECTOR end; | ||
267 | function --[[integer]] LSL.llListFindList(--[[list]] l, --[[list]] l1) return 0 end; | ||
268 | function --[[list]] LSL.llListInsertList(--[[list]] l, --[[list]] l1,--[[integer]] index) return {} end; | ||
269 | function --[[integer]] LSL.llGetListLength(--[[list]] l) return 0 end; | ||
270 | function --[[list]] LSL.llListReplaceList(--[[list]] l, --[[list]] part,--[[integer]] start,--[[integer]] eNd) return {} end; | ||
271 | function --[[list]] LSL.llListSort(--[[list]] l,--[[integer]] stride,--[[integer]] ascending) return {} end; | ||
272 | |||
273 | function --[[key]] LSL.llAvatarOnSitTarget() return LSL.NULL_KEY end; | ||
274 | function --[[list]] LSL.llGetAnimationList(--[[key]] id) return {} end; | ||
275 | function --[[key]] LSL.llGetKey() return LSL.NULL_KEY end; | ||
276 | function --[[key]] LSL.llGetOwner() return LSL.NULL_KEY end; | ||
277 | function --[[integer]] LSL.llGetPermissions() return 0 end; | ||
278 | function --[[key]] LSL.llGetPermissionsKey() return LSL.NULL_KEY end; | ||
279 | function --[[string]] LSL.llKey2Name(--[[key]] avatar) return "" end; | ||
280 | function LSL.llRequestPermissions(--[[key]] avatar,--[[integer]] perms) end; | ||
281 | function LSL.llStartAnimation(--[[string]] anim) end; | ||
282 | function LSL.llStopAnimation(--[[string]] anim) end; | ||
283 | function LSL.llUnSit(--[[key]] avatar) end; | ||
284 | |||
285 | function LSL.llDialog(--[[key]] avatar, --[[string]] caption, --[[list]] arseBackwardsMenu,--[[integer]] channel) end; | ||
286 | function --[[integer]] LSL.llListen(--[[integer]] channel, --[[string]] name, --[[key]] id, --[[string]] msg) return 0 end; | ||
287 | function LSL.llListenRemove(--[[integer]] handle) end; | ||
288 | function LSL.llOwnerSay(--[[string]] text) end; | ||
289 | function LSL.llSay(--[[integer]] channel, --[[string]] text) end; | ||
290 | function LSL.llShout(--[[integer]] channel, --[[string]] text) end; | ||
291 | function LSL.llWhisper(--[[integer]] channel, --[[string]] text) end; | ||
292 | |||
293 | function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string]] text, --[[key]] aKey) end; | ||
294 | |||
295 | |||
296 | return LSL; | ||
297 | |||