diff options
author | David Walter Seikel | 2012-02-24 00:42:50 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-24 00:42:50 +1000 |
commit | 0ed049db227f0a25a631b64ee85549c778fb9567 (patch) | |
tree | a9c2a29556666013d3dfccbe1a5a1291f957b89b /LuaSL/src | |
parent | Implement llDetectedKey(). (diff) | |
download | SledjHamr-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.lua | 137 |
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 = ""; | |||
30 | local running = true | 30 | local running = true |
31 | local paused = false | 31 | local paused = false |
32 | local currentState = {} | 32 | local currentState = {} |
33 | local detectedGroups = {} | ||
34 | local detectedGrabs = {} | ||
33 | local detectedKeys = {} | 35 | local detectedKeys = {} |
36 | local detectedLinkNumbers = {} | ||
34 | local detectedNames = {} | 37 | local detectedNames = {} |
38 | local detectedOwners = {} | ||
39 | local detectedPoss = {} | ||
40 | local detectedRots = {} | ||
41 | local detectedTouchBinormals = {} | ||
42 | local detectedTouchFaces = {} | ||
43 | local detectedTouchNormals = {} | ||
44 | local detectedTouchPoss = {} | ||
45 | local detectedTouchSTs = {} | ||
46 | local detectedTouchUVs = {} | ||
47 | local detectedTypes = {} | ||
48 | local detectedVels = {} | ||
35 | local waitAndProcess | 49 | local waitAndProcess |
36 | 50 | ||
37 | 51 | ||
@@ -71,22 +85,77 @@ events = {} | |||
71 | function stop() paused = true end | 85 | function stop() paused = true end |
72 | function quit() running = false end | 86 | function quit() running = false end |
73 | 87 | ||
74 | function events.detectedKeys(list) | 88 | function events.detectedGroups(list) detectedGroups = list end |
75 | detectedKeys = list | 89 | function events.detectedGrabs(list) detectedGrabs = list end |
76 | end | 90 | function events.detectedKeys(list) detectedKeys = list end |
77 | 91 | function events.detectedLinkNumbers(list) detectedLinkNumbers = list end | |
78 | function events.detectedNames(list) | 92 | function events.detectedNames(list) detectedNames = list end |
79 | detectedNames = list | 93 | function events.detectedOwners(list) detectedOwners = list end |
80 | end | 94 | function events.detectedPoss(list) detectedPoss = list end |
81 | 95 | function events.detectedRots(list) detectedRots = list end | |
82 | function events.touch_start(number) | 96 | function events.detectedTouchBinormals(list) detectedTouchBinormals = list end |
83 | --print_table_start(detectedKeys, "", "detectedKeys") | 97 | function events.detectedTouchFaces(list) detectedTouchFaces = list end |
84 | --print_table_start(detectedNames, "", "detectedNames") | 98 | function events.detectedTouchNormals(list) detectedTouchNormals = list end |
85 | --print(scriptName .. ".touch_start(" .. number .. ")\n") | 99 | function events.detectedTouchPoss(list) detectedTouchPoss = list end |
86 | if nil ~= currentState.touch_start then currentState.touch_start(number) end | 100 | function events.detectedTouchSTs(list) detectedTouchSTs = list end |
101 | function events.detectedTouchUVs(list) detectedTouchUVs = list end | ||
102 | function events.detectedTypes(list) detectedTypes = list end | ||
103 | function events.detectedVels(list) detectedVels = list end | ||
104 | |||
105 | function events.detectsClear() | ||
106 | detectedGroups = {} | ||
107 | detectedGrabs = {} | ||
87 | detectedKeys = {} | 108 | detectedKeys = {} |
109 | detectedLinkNumbers = {} | ||
88 | detectedNames = {} | 110 | detectedNames = {} |
89 | end | 111 | detectedOwners = {} |
112 | detectedPoss = {} | ||
113 | detectedRots = {} | ||
114 | detectedTouchBinormals = {} | ||
115 | detectedTouchFaces = {} | ||
116 | detectedTouchNormals = {} | ||
117 | detectedTouchPoss = {} | ||
118 | detectedTouchSTs = {} | ||
119 | detectedTouchUVs = {} | ||
120 | detectedTypes = {} | ||
121 | detectedVels = {} | ||
122 | end | ||
123 | |||
124 | function 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 | ||
125 | function events.at_target(tnum, targetpos, ourpos) if nil ~= currentState.at_target then currentState.at_target(tnum, targetpos, ourpos) end events.detectsClear() end | ||
126 | function events.attach(id) if nil ~= currentState.attach then currentState.attach(id) end events.detectsClear() end | ||
127 | function events.changed(change) if nil ~= currentState.changed then currentState.changed(change) end events.detectsClear() end | ||
128 | function events.collision_start(num_detected) if nil ~= currentState.collision_start then currentState.collision_start(num_detected) end events.detectsClear() end | ||
129 | function events.collision(num_detected) if nil ~= currentState.collision then currentState.collision(num_detected) end events.detectsClear() end | ||
130 | function events.collision_end(num_detected) if nil ~= currentState.collision_end then currentState.collision_end(num_detected) end events.detectsClear() end | ||
131 | function events.control(id, held, changed) if nil ~= currentState.control then currentState.control(id, held, changed) end events.detectsClear() end | ||
132 | function events.dataserver(queryid, data) if nil ~= currentState.dataserver then currentState.dataserver(queryid, data) end events.detectsClear() end | ||
133 | function 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 | ||
134 | function 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 | ||
135 | function 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 | ||
136 | function events.land_collision_start(pos) if nil ~= currentState.land_collision_start then currentState.land_collision_start(pos) end events.detectsClear() end | ||
137 | function events.land_collision(pos) if nil ~= currentState.land_collision then currentState.land_collision(pos) end events.detectsClear() end | ||
138 | function events.land_collision_end(pos) if nil ~= currentState.land_collision_end then currentState.land_collision_end(pos) end events.detectsClear() end | ||
139 | function 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 | ||
140 | function events.listen(channel, name, id, message) if nil ~= currentState.listen then currentState.listen(channel, name, id, message) end events.detectsClear() end | ||
141 | function events.money(id, amount) if nil ~= currentState.money then currentState.money(id, amount) end events.detectsClear() end | ||
142 | function events.moving_start() if nil ~= currentState.moving_start then currentState.moving_start() end events.detectsClear() end | ||
143 | function events.moving_end() if nil ~= currentState.moving_end then currentState.moving_end() end events.detectsClear() end | ||
144 | function events.no_sensor() if nil ~= currentState.no_sensor then currentState.no_sensor() end events.detectsClear() end | ||
145 | function events.not_at_rot_target() if nil ~= currentState.not_at_rot_target then currentState.not_at_rot_target() end events.detectsClear() end | ||
146 | function events.not_at_target() if nil ~= currentState.not_at_target then currentState.not_at_target() end events.detectsClear() end | ||
147 | function events.object_rez(id) if nil ~= currentState.object_rez then currentState.object_rez() end events.detectsClear() end | ||
148 | function events.on_rez(start_param) if nil ~= currentState.on_rezz then currentState.on_rez(start_param) end events.detectsClear() end | ||
149 | function 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 | ||
150 | function events.run_time_permissions(perm) if nil ~= currentState.run_time_permisions then currentState.run_time_permissions(perm) end events.detectsClear() end | ||
151 | function events.sensor(num_detected) if nil ~= currentState.sensor then currentState.sensor(num_detected) end events.detectsClear() end | ||
152 | function events.state_entry() if nil ~= currentState.state_entry then currentState.state_entry() end events.detectsClear() end | ||
153 | function events.state_exit() if nil ~= currentState.state_exit then currentState.state_exit() end events.detectsClear() end | ||
154 | function events.timer() if nil ~= currentState.timer then currentState.timer() end events.detectsClear() end | ||
155 | function events.touch_start(num_detected) if nil ~= currentState.touch_start then currentState.touch_start(num_detected) end events.detectsClear() end | ||
156 | function events.touch(num_detected) if nil ~= currentState.touch then currentState.touch(num_detected) end events.detectsClear() end | ||
157 | function events.touch_end(num_detected) if nil ~= currentState.touch_end then currentState.touch_end(num_detected) end events.detectsClear() end | ||
158 | function 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") | |||
342 | newFunc("", "llUnSit", "key avatar") | 415 | newFunc("", "llUnSit", "key avatar") |
343 | 416 | ||
344 | -- LSL collision / detect / sensor functions | 417 | -- LSL collision / detect / sensor functions |
345 | newFunc("key", "llDetectedGroup", "integer index") | 418 | newFunc("integer", "llDetectedGroup", "integer index") |
419 | newFunc("vector", "llDetectedGrab", "integer index") | ||
346 | newFunc("key", "llDetectedKey", "integer index") | 420 | newFunc("key", "llDetectedKey", "integer index") |
421 | newFunc("integer", "llDetectedLinkNumber", "integer index") | ||
422 | newFunc("string", "llDetectedName", "integer index") | ||
423 | newFunc("key", "llDetectedOwner", "integer index") | ||
424 | newFunc("vector", "llDetectedPos", "integer index") | ||
425 | newFunc("rotation", "llDetectedRot", "integer index") | ||
426 | newFunc("vector", "llDetectedTouchBinormal", "integer index") | ||
427 | newFunc("integer", "llDetectedTouchFace", "integer index") | ||
428 | newFunc("vector", "llDetectedTouchNormal", "integer index") | ||
429 | newFunc("vector", "llDetectedTouchPos", "integer index") | ||
430 | newFunc("vector", "llDetectedTouchST", "integer index") | ||
431 | newFunc("vector", "llDetectedTouchUV", "integer index") | ||
432 | newFunc("integer", "llDetectedType", "integer index") | ||
433 | newFunc("vector", "llDetectedVel", "integer index") | ||
434 | |||
347 | 435 | ||
348 | -- LSL communications functions | 436 | -- LSL communications functions |
349 | newFunc("", "llDialog", "key avatar", "string caption", "list arseBackwardsMenu", "integer channel") | 437 | newFunc("", "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 |
447 | function --[[key]] LSL.llDetectedKey(--[[integer]] index) | 535 | function --[[integer]] LSL.llDetectedGroup( --[[integer]] index) return detectedGroups [index + 1] or false end |
448 | return detectedKeys[index + 1] | 536 | function --[[vector]] LSL.llDetectedGrab( --[[integer]] index) return detectedGrabs [index + 1] or LSL.ZERO_VECTOR end |
449 | end | 537 | function --[[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 |
538 | function --[[integer]] LSL.llDetectedLinkNumber( --[[integer]] index) return detectedLinkNumbers [index + 1] or 0 end | ||
539 | function --[[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. | ||
540 | function --[[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 | ||
541 | function --[[vector]] LSL.llDetectedPos( --[[integer]] index) return detectedPoss [index + 1] or LSL.ZERO_VECTOR end | ||
542 | function --[[rotation]] LSL.llDetectedRot( --[[integer]] index) return detectedRots [index + 1] or LSL.ZERO_ROTATION end | ||
543 | function --[[vector]] LSL.llDetectedTouchBinormal( --[[integer]] index) return detectedTouchBinormals [index + 1] or LSL.TOUCH_INVALID_VECTOR end | ||
544 | function --[[integer]] LSL.llDetectedTouchFace( --[[integer]] index) return detectedTouchFaces [index + 1] or LSL.TOUCH_INVALID_FACE end | ||
545 | function --[[vector]] LSL.llDetectedTouchNormal( --[[integer]] index) return detectedTouchNormals [index + 1] or LSL.TOUCH_INVALID_VECTOR end | ||
546 | function --[[vector]] LSL.llDetectedTouchPos( --[[integer]] index) return detectedTouchPoss [index + 1] or LSL.TOUCH_INVALID_VECTOR end | ||
547 | function --[[vector]] LSL.llDetectedTouchST( --[[integer]] index) return detectedTouchSTs [index + 1] or LSL.TOUCH_INVALID_TEXCOORD end | ||
548 | function --[[vector]] LSL.llDetectedTouchUV( --[[integer]] index) return detectedTouchUVs [index + 1] or LSL.TOUCH_INVALID_TEXCOORD end | ||
549 | function --[[integer]] LSL.llDetectedType( --[[integer]] index) return detectedTypes [index + 1] or 0 end | ||
550 | function --[[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. |