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