diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LSL.lua | 129 |
1 files changed, 103 insertions, 26 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua index 12b3236..ca92380 100644 --- a/LuaSL/src/LSL.lua +++ b/LuaSL/src/LSL.lua | |||
@@ -314,69 +314,146 @@ function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string] | |||
314 | 314 | ||
315 | function --[[list]] LSL.llCSV2List(--[[string]] text) return {} end; | 315 | function --[[list]] LSL.llCSV2List(--[[string]] text) return {} end; |
316 | function --[[list]] LSL.llDeleteSubList(--[[list]] l,--[[integer]] start,--[[integer]] eNd) | 316 | function --[[list]] LSL.llDeleteSubList(--[[list]] l,--[[integer]] start,--[[integer]] eNd) |
317 | local temp = {} | 317 | local result = {} |
318 | local x = 1 | 318 | local x = 1 |
319 | 319 | ||
320 | -- Deal with the impedance mismatch. | 320 | -- Deal with the impedance mismatch. |
321 | start = start + 1 | 321 | start = start + 1 |
322 | eNd = eNd + 1 | 322 | eNd = eNd + 1 |
323 | for i = 1,#l do | 323 | for i = 1,#l do |
324 | if i < start then temp[x] = l[i]; x = x + 1 | 324 | if i < start then result[x] = l[i]; x = x + 1 |
325 | elseif i > eNd then temp[x] = l[i]; x = x + 1 | 325 | elseif i > eNd then result[x] = l[i]; x = x + 1 |
326 | end | 326 | end |
327 | end | 327 | end |
328 | 328 | ||
329 | return temp | 329 | return result |
330 | end | ||
331 | |||
332 | function --[[string]] LSL.llDumpList2String(--[[list]] l, --[[string]] separator) | ||
333 | local result = "" | ||
334 | for i = 1,#l do | ||
335 | if "" ~= result then result = result .. separator end | ||
336 | result = result .. l[i] | ||
337 | end | ||
338 | return result | ||
339 | end | ||
340 | |||
341 | function --[[string]] LSL.llList2CSV(--[[list]] l) | ||
342 | return LSL.llDumpList2String(l, ",") | ||
330 | end | 343 | end |
331 | 344 | ||
332 | function --[[string]] LSL.llDumpList2String(--[[list]] l, --[[string]] separator) return "" end; | ||
333 | function --[[string]] LSL.llList2CSV(--[[list]] l) return "" end; | ||
334 | function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) | 345 | function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) |
335 | local temp = tonumber(l[index]) | 346 | local result = tonumber(l[index]) |
336 | if nil == temp then temp = 0.0 end | 347 | if nil == result then result = 0.0 end |
337 | return temp; | 348 | return result |
338 | end | 349 | end |
339 | 350 | ||
340 | function --[[integer]] LSL.llList2Integer(--[[list]] l,--[[integer]] index) | 351 | function --[[integer]] LSL.llList2Integer(--[[list]] l,--[[integer]] index) |
341 | local temp = tonumber(l[index+1]) | 352 | local result = tonumber(l[index+1]) |
342 | if nil == temp then temp = 0 end | 353 | if nil == result then result = 0 end |
343 | return temp; | 354 | return result |
344 | end | 355 | end |
345 | 356 | ||
346 | function --[[key]] LSL.llList2Key(--[[list]] l,--[[integer]] index) | 357 | function --[[key]] LSL.llList2Key(--[[list]] l,--[[integer]] index) |
347 | local temp = l[index+1] | 358 | local result = l[index+1] |
348 | if temp then return "" .. temp else return LSL.NULL_KEY end | 359 | if result then return "" .. result else return LSL.NULL_KEY end |
360 | end | ||
361 | |||
362 | function --[[list]] LSL.llList2List(--[[list]] l,--[[integer]] start,--[[integer]] eNd) | ||
363 | local result = {} | ||
364 | local x = 1 | ||
365 | |||
366 | --[[ TODO - | ||
367 | Using negative numbers for start and/or end causes the index to count backwards from the length of the list, so 0, -1 would capture the entire list. | ||
368 | If start is larger than end the list returned is the exclusion of the entries, so 6, 4 would give the entire list except for the 5th entry. | ||
369 | ]] | ||
370 | |||
371 | -- Deal with the impedance mismatch. | ||
372 | start = start + 1 | ||
373 | eNd = eNd + 1 | ||
374 | for i = 1,#l do | ||
375 | if i >= start then result[x] = l[i]; x = x + 1 | ||
376 | elseif i <= eNd then result[x] = l[i]; x = x + 1 | ||
377 | end | ||
378 | end | ||
379 | |||
380 | return result | ||
349 | end | 381 | end |
350 | 382 | ||
351 | function --[[list]] LSL.llList2List(--[[list]] l,--[[integer]] start,--[[integer]] eNd) return {} end; | ||
352 | function --[[string]] LSL.llList2String(--[[list]] l,--[[integer]] index) | 383 | function --[[string]] LSL.llList2String(--[[list]] l,--[[integer]] index) |
353 | local temp = l[index+1] | 384 | local result = l[index+1] |
354 | if temp then return "" .. temp else return "" end | 385 | if result then return "" .. result else return "" end |
355 | end | 386 | end |
356 | 387 | ||
357 | function --[[rotation]] LSL.llList2Rotation(--[[list]] l,--[[integer]] index) | 388 | function --[[rotation]] LSL.llList2Rotation(--[[list]] l,--[[integer]] index) |
358 | local temp = l[index+1] | 389 | local result = l[index+1] |
359 | if nil == temp then temp = LSL.ZERO_ROTATION end | 390 | if nil == result then result = LSL.ZERO_ROTATION end |
360 | -- TODO - check if it's not an actual rotation, then return LSS.ZERO_ROTATION | 391 | -- TODO - check if it's not an actual rotation, then return LSS.ZERO_ROTATION |
361 | return temp; | 392 | return result |
362 | end | 393 | end |
363 | 394 | ||
364 | function --[[vector]] LSL.llList2Vector(--[[list]] l,--[[integer]] index) | 395 | function --[[vector]] LSL.llList2Vector(--[[list]] l,--[[integer]] index) |
365 | local temp = l[index+1] | 396 | local result = l[index+1] |
366 | if nil == temp then temp = LSL.ZERO_VECTOR end | 397 | if nil == result then result = LSL.ZERO_VECTOR end |
367 | -- TODO - check if it's not an actual rotation, then return LSS.ZERO_VECTOR | 398 | -- TODO - check if it's not an actual rotation, then return LSS.ZERO_VECTOR |
368 | return temp; | 399 | return result |
369 | end | 400 | end |
370 | 401 | ||
371 | function --[[integer]] LSL.llListFindList(--[[list]] l, --[[list]] l1) return 0 end; | 402 | function --[[integer]] LSL.llListFindList(--[[list]] l, --[[list]] l1) return 0 end; |
372 | function --[[list]] LSL.llListInsertList(--[[list]] l, --[[list]] l1,--[[integer]] index) return {} end; | 403 | function --[[list]] LSL.llListInsertList(--[[list]] l, --[[list]] l1,--[[integer]] index) |
404 | local result = {} | ||
405 | local x = 1 | ||
406 | local y | ||
407 | for i = 1,index do | ||
408 | result[x] = l[i] | ||
409 | x = x + 1 | ||
410 | end | ||
411 | y = x | ||
412 | for i = 1,#ll do | ||
413 | result[x] = ll[i] | ||
414 | x = x + 1 | ||
415 | end | ||
416 | for i = y,#l do | ||
417 | result[x] = l[i] | ||
418 | x = x + 1 | ||
419 | end | ||
420 | return result | ||
421 | end | ||
422 | |||
373 | function --[[integer]] LSL.llGetListLength(--[[list]] l) | 423 | function --[[integer]] LSL.llGetListLength(--[[list]] l) |
374 | return #l | 424 | return #l |
375 | end | 425 | end |
376 | 426 | ||
377 | function --[[list]] LSL.llListReplaceList(--[[list]] l, --[[list]] part,--[[integer]] start,--[[integer]] eNd) return {} end; | 427 | function --[[list]] LSL.llListReplaceList(--[[list]] l, --[[list]] part,--[[integer]] start,--[[integer]] eNd) |
378 | function --[[list]] LSL.llListSort(--[[list]] l,--[[integer]] stride,--[[integer]] ascending) return {} end; | 428 | local result = {} |
429 | local x = 1 | ||
430 | local y | ||
431 | for i = 1,index do | ||
432 | result[x] = l[i] | ||
433 | x = x + 1 | ||
434 | end | ||
435 | for i = 1,#part do | ||
436 | result[x] = part[i] | ||
437 | x = x + 1 | ||
438 | end | ||
439 | for i = index,#l do | ||
440 | result[x] = l[i] | ||
441 | x = x + 1 | ||
442 | end | ||
443 | return result | ||
444 | end | ||
445 | |||
446 | function --[[list]] LSL.llListSort(--[[list]] l,--[[integer]] stride,--[[integer]] ascending) | ||
447 | local result = {} | ||
379 | 448 | ||
449 | -- TODO - Deal with stride and ascending. | ||
450 | for i = 1,#l do | ||
451 | result[x] = l[i]; x = x + 1 | ||
452 | end | ||
453 | table.sort(result) | ||
454 | |||
455 | return result | ||
456 | end | ||
380 | 457 | ||
381 | 458 | ||
382 | -- Crements stuff. | 459 | -- Crements stuff. |