aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-24 00:42:50 +1000
committerDavid Walter Seikel2012-02-24 00:42:50 +1000
commit0ed049db227f0a25a631b64ee85549c778fb9567 (patch)
treea9c2a29556666013d3dfccbe1a5a1291f957b89b /LuaSL/src
parentImplement llDetectedKey(). (diff)
downloadSledjHamr-0ed049db227f0a25a631b64ee85549c778fb9567.zip
SledjHamr-0ed049db227f0a25a631b64ee85549c778fb9567.tar.gz
SledjHamr-0ed049db227f0a25a631b64ee85549c778fb9567.tar.bz2
SledjHamr-0ed049db227f0a25a631b64ee85549c778fb9567.tar.xz
Implemented events and detects.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LSL.lua137
1 files changed, 119 insertions, 18 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua
index 5f103fc..3810abc 100644
--- a/LuaSL/src/LSL.lua
+++ b/LuaSL/src/LSL.lua
@@ -30,8 +30,22 @@ local scriptName = "";
30local running = true 30local running = true
31local paused = false 31local paused = false
32local currentState = {} 32local currentState = {}
33local detectedGroups = {}
34local detectedGrabs = {}
33local detectedKeys = {} 35local detectedKeys = {}
36local detectedLinkNumbers = {}
34local detectedNames = {} 37local detectedNames = {}
38local detectedOwners = {}
39local detectedPoss = {}
40local detectedRots = {}
41local detectedTouchBinormals = {}
42local detectedTouchFaces = {}
43local detectedTouchNormals = {}
44local detectedTouchPoss = {}
45local detectedTouchSTs = {}
46local detectedTouchUVs = {}
47local detectedTypes = {}
48local detectedVels = {}
35local waitAndProcess 49local waitAndProcess
36 50
37 51
@@ -71,22 +85,77 @@ events = {}
71function stop() paused = true end 85function stop() paused = true end
72function quit() running = false end 86function quit() running = false end
73 87
74function events.detectedKeys(list) 88function events.detectedGroups(list) detectedGroups = list end
75 detectedKeys = list 89function events.detectedGrabs(list) detectedGrabs = list end
76end 90function events.detectedKeys(list) detectedKeys = list end
77 91function events.detectedLinkNumbers(list) detectedLinkNumbers = list end
78function events.detectedNames(list) 92function events.detectedNames(list) detectedNames = list end
79 detectedNames = list 93function events.detectedOwners(list) detectedOwners = list end
80end 94function events.detectedPoss(list) detectedPoss = list end
81 95function events.detectedRots(list) detectedRots = list end
82function events.touch_start(number) 96function events.detectedTouchBinormals(list) detectedTouchBinormals = list end
83--print_table_start(detectedKeys, "", "detectedKeys") 97function events.detectedTouchFaces(list) detectedTouchFaces = list end
84--print_table_start(detectedNames, "", "detectedNames") 98function events.detectedTouchNormals(list) detectedTouchNormals = list end
85--print(scriptName .. ".touch_start(" .. number .. ")\n") 99function events.detectedTouchPoss(list) detectedTouchPoss = list end
86 if nil ~= currentState.touch_start then currentState.touch_start(number) end 100function events.detectedTouchSTs(list) detectedTouchSTs = list end
101function events.detectedTouchUVs(list) detectedTouchUVs = list end
102function events.detectedTypes(list) detectedTypes = list end
103function events.detectedVels(list) detectedVels = list end
104
105function events.detectsClear()
106 detectedGroups = {}
107 detectedGrabs = {}
87 detectedKeys = {} 108 detectedKeys = {}
109 detectedLinkNumbers = {}
88 detectedNames = {} 110 detectedNames = {}
89end 111 detectedOwners = {}
112 detectedPoss = {}
113 detectedRots = {}
114 detectedTouchBinormals = {}
115 detectedTouchFaces = {}
116 detectedTouchNormals = {}
117 detectedTouchPoss = {}
118 detectedTouchSTs = {}
119 detectedTouchUVs = {}
120 detectedTypes = {}
121 detectedVels = {}
122end
123
124function events.at_rot_target(tnum, targetrot, ourrot) if nil ~= currentState.at_rot_target then currentState.at_rot_target(tnum, targetrot, ourrot) end events.detectsClear() end
125function events.at_target(tnum, targetpos, ourpos) if nil ~= currentState.at_target then currentState.at_target(tnum, targetpos, ourpos) end events.detectsClear() end
126function events.attach(id) if nil ~= currentState.attach then currentState.attach(id) end events.detectsClear() end
127function events.changed(change) if nil ~= currentState.changed then currentState.changed(change) end events.detectsClear() end
128function events.collision_start(num_detected) if nil ~= currentState.collision_start then currentState.collision_start(num_detected) end events.detectsClear() end
129function events.collision(num_detected) if nil ~= currentState.collision then currentState.collision(num_detected) end events.detectsClear() end
130function events.collision_end(num_detected) if nil ~= currentState.collision_end then currentState.collision_end(num_detected) end events.detectsClear() end
131function events.control(id, held, changed) if nil ~= currentState.control then currentState.control(id, held, changed) end events.detectsClear() end
132function events.dataserver(queryid, data) if nil ~= currentState.dataserver then currentState.dataserver(queryid, data) end events.detectsClear() end
133function events.email(Time, address, subj, message, num_left) if nil ~= currentState.email then currentState.email(Time, address, subj, message, num_left) end events.detectsClear() end
134function events.http_request(request_id, status, metadata, body) if nil ~= currentState.http_request then currentState.http_request(request_id, status, metadata, body) end events.detectsClear() end
135function events.http_response(request_id, status, metadata, body) if nil ~= currentState.http_response then currentState.http_response(request_id, status, metadata, body) end events.detectsClear() end
136function events.land_collision_start(pos) if nil ~= currentState.land_collision_start then currentState.land_collision_start(pos) end events.detectsClear() end
137function events.land_collision(pos) if nil ~= currentState.land_collision then currentState.land_collision(pos) end events.detectsClear() end
138function events.land_collision_end(pos) if nil ~= currentState.land_collision_end then currentState.land_collision_end(pos) end events.detectsClear() end
139function events.link_message(sender_num, num, str, id) if nil ~= currentState.link_message then currentState.link_message(sender_num, num, str, id) end events.detectsClear() end
140function events.listen(channel, name, id, message) if nil ~= currentState.listen then currentState.listen(channel, name, id, message) end events.detectsClear() end
141function events.money(id, amount) if nil ~= currentState.money then currentState.money(id, amount) end events.detectsClear() end
142function events.moving_start() if nil ~= currentState.moving_start then currentState.moving_start() end events.detectsClear() end
143function events.moving_end() if nil ~= currentState.moving_end then currentState.moving_end() end events.detectsClear() end
144function events.no_sensor() if nil ~= currentState.no_sensor then currentState.no_sensor() end events.detectsClear() end
145function events.not_at_rot_target() if nil ~= currentState.not_at_rot_target then currentState.not_at_rot_target() end events.detectsClear() end
146function events.not_at_target() if nil ~= currentState.not_at_target then currentState.not_at_target() end events.detectsClear() end
147function events.object_rez(id) if nil ~= currentState.object_rez then currentState.object_rez() end events.detectsClear() end
148function events.on_rez(start_param) if nil ~= currentState.on_rezz then currentState.on_rez(start_param) end events.detectsClear() end
149function events.remote_data(event_type, channel, message_id, sender, idata, sdata) if nil ~= currentState.remote_data then currentState.remote_data(event_type, channel, message_id, sender, idata, sdata) end events.detectsClear() end
150function events.run_time_permissions(perm) if nil ~= currentState.run_time_permisions then currentState.run_time_permissions(perm) end events.detectsClear() end
151function events.sensor(num_detected) if nil ~= currentState.sensor then currentState.sensor(num_detected) end events.detectsClear() end
152function events.state_entry() if nil ~= currentState.state_entry then currentState.state_entry() end events.detectsClear() end
153function events.state_exit() if nil ~= currentState.state_exit then currentState.state_exit() end events.detectsClear() end
154function events.timer() if nil ~= currentState.timer then currentState.timer() end events.detectsClear() end
155function events.touch_start(num_detected) if nil ~= currentState.touch_start then currentState.touch_start(num_detected) end events.detectsClear() end
156function events.touch(num_detected) if nil ~= currentState.touch then currentState.touch(num_detected) end events.detectsClear() end
157function events.touch_end(num_detected) if nil ~= currentState.touch_end then currentState.touch_end(num_detected) end events.detectsClear() end
158function events.transaction_result(id, success, data) if nil ~= currentState.transaction_result then currentState.transaction_result(id, success, data) end events.detectsClear() end
90 159
91 160
92-- LSL function and constant creation stuff. 161-- LSL function and constant creation stuff.
@@ -305,6 +374,10 @@ local constants =
305 newConst("integer", "TRUE", 1), 374 newConst("integer", "TRUE", 1),
306 newConst("integer", "FALSE", 0), 375 newConst("integer", "FALSE", 0),
307 376
377 newConst("integer", "TOUCH_INVALID_FACE", 0x7FFFFFFF),
378 newConst("vector", "TOUCH_INVALID_TEXCOORD", {x=-1.0, y=-1.0, z=0.0}),
379 newConst("vector", "TOUCH_INVALID_VECTOR", {x=0.0, y=0.0, z=0.0}),
380
308 newConst("integer", "TYPE_INTEGER", 1), 381 newConst("integer", "TYPE_INTEGER", 1),
309 newConst("integer", "TYPE_FLOAT", 2), 382 newConst("integer", "TYPE_FLOAT", 2),
310 newConst("integer", "TYPE_STRING", 3), 383 newConst("integer", "TYPE_STRING", 3),
@@ -342,8 +415,23 @@ newFunc("", "llStopAnimation", "string anim")
342newFunc("", "llUnSit", "key avatar") 415newFunc("", "llUnSit", "key avatar")
343 416
344-- LSL collision / detect / sensor functions 417-- LSL collision / detect / sensor functions
345newFunc("key", "llDetectedGroup", "integer index") 418newFunc("integer", "llDetectedGroup", "integer index")
419newFunc("vector", "llDetectedGrab", "integer index")
346newFunc("key", "llDetectedKey", "integer index") 420newFunc("key", "llDetectedKey", "integer index")
421newFunc("integer", "llDetectedLinkNumber", "integer index")
422newFunc("string", "llDetectedName", "integer index")
423newFunc("key", "llDetectedOwner", "integer index")
424newFunc("vector", "llDetectedPos", "integer index")
425newFunc("rotation", "llDetectedRot", "integer index")
426newFunc("vector", "llDetectedTouchBinormal", "integer index")
427newFunc("integer", "llDetectedTouchFace", "integer index")
428newFunc("vector", "llDetectedTouchNormal", "integer index")
429newFunc("vector", "llDetectedTouchPos", "integer index")
430newFunc("vector", "llDetectedTouchST", "integer index")
431newFunc("vector", "llDetectedTouchUV", "integer index")
432newFunc("integer", "llDetectedType", "integer index")
433newFunc("vector", "llDetectedVel", "integer index")
434
347 435
348-- LSL communications functions 436-- LSL communications functions
349newFunc("", "llDialog", "key avatar", "string caption", "list arseBackwardsMenu", "integer channel") 437newFunc("", "llDialog", "key avatar", "string caption", "list arseBackwardsMenu", "integer channel")
@@ -444,9 +532,22 @@ function --[[integer]] LSL.llGetInventoryType(--[[string]] name) return LSL.INV
444 532
445 533
446-- LSL collision / detect / sensor functions 534-- LSL collision / detect / sensor functions
447function --[[key]] LSL.llDetectedKey(--[[integer]] index) 535function --[[integer]] LSL.llDetectedGroup( --[[integer]] index) return detectedGroups [index + 1] or false end
448 return detectedKeys[index + 1] 536function --[[vector]] LSL.llDetectedGrab( --[[integer]] index) return detectedGrabs [index + 1] or LSL.ZERO_VECTOR end
449end 537function --[[key]] LSL.llDetectedKey( --[[integer]] index) return detectedKeys [index + 1] or LSL.NULL_KEY end -- LL says "returns empty key" which is "", but LSL Wiki says NULL_KEY
538function --[[integer]] LSL.llDetectedLinkNumber( --[[integer]] index) return detectedLinkNumbers [index + 1] or 0 end
539function --[[string]] LSL.llDetectedName( --[[integer]] index) return detectedNames [index + 1] or "" end -- LL says it returns NULL_KEY, LSL Wiki says an empty string. Apparently there used to be an exploit for creating multi kb names, normally they are 255 characters.
540function --[[key]] LSL.llDetectedOwner( --[[integer]] index) return detectedOwners [index + 1] or LSL.NULL_KEY end -- LL says "returns empty key" which is "", but LSL Wiki says NULL_KEY
541function --[[vector]] LSL.llDetectedPos( --[[integer]] index) return detectedPoss [index + 1] or LSL.ZERO_VECTOR end
542function --[[rotation]] LSL.llDetectedRot( --[[integer]] index) return detectedRots [index + 1] or LSL.ZERO_ROTATION end
543function --[[vector]] LSL.llDetectedTouchBinormal( --[[integer]] index) return detectedTouchBinormals [index + 1] or LSL.TOUCH_INVALID_VECTOR end
544function --[[integer]] LSL.llDetectedTouchFace( --[[integer]] index) return detectedTouchFaces [index + 1] or LSL.TOUCH_INVALID_FACE end
545function --[[vector]] LSL.llDetectedTouchNormal( --[[integer]] index) return detectedTouchNormals [index + 1] or LSL.TOUCH_INVALID_VECTOR end
546function --[[vector]] LSL.llDetectedTouchPos( --[[integer]] index) return detectedTouchPoss [index + 1] or LSL.TOUCH_INVALID_VECTOR end
547function --[[vector]] LSL.llDetectedTouchST( --[[integer]] index) return detectedTouchSTs [index + 1] or LSL.TOUCH_INVALID_TEXCOORD end
548function --[[vector]] LSL.llDetectedTouchUV( --[[integer]] index) return detectedTouchUVs [index + 1] or LSL.TOUCH_INVALID_TEXCOORD end
549function --[[integer]] LSL.llDetectedType( --[[integer]] index) return detectedTypes [index + 1] or 0 end
550function --[[vector]] LSL.llDetectedVel( --[[integer]] index) return detectedVels [index + 1] or LSL.ZERO_VECTOR end
450 551
451 552
452-- LSL list functions. 553-- LSL list functions.