aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LSL.lua129
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
315function --[[list]] LSL.llCSV2List(--[[string]] text) return {} end; 315function --[[list]] LSL.llCSV2List(--[[string]] text) return {} end;
316function --[[list]] LSL.llDeleteSubList(--[[list]] l,--[[integer]] start,--[[integer]] eNd) 316function --[[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
330end
331
332function --[[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
339end
340
341function --[[string]] LSL.llList2CSV(--[[list]] l)
342 return LSL.llDumpList2String(l, ",")
330end 343end
331 344
332function --[[string]] LSL.llDumpList2String(--[[list]] l, --[[string]] separator) return "" end;
333function --[[string]] LSL.llList2CSV(--[[list]] l) return "" end;
334function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) 345function --[[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
338end 349end
339 350
340function --[[integer]] LSL.llList2Integer(--[[list]] l,--[[integer]] index) 351function --[[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
344end 355end
345 356
346function --[[key]] LSL.llList2Key(--[[list]] l,--[[integer]] index) 357function --[[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
360end
361
362function --[[list]] LSL.llList2List(--[[list]] l,--[[integer]] start,--[[integer]] eNd)
363 local result = {}
364 local x = 1
365
366 --[[ TODO -
367Using 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.
368If 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
349end 381end
350 382
351function --[[list]] LSL.llList2List(--[[list]] l,--[[integer]] start,--[[integer]] eNd) return {} end;
352function --[[string]] LSL.llList2String(--[[list]] l,--[[integer]] index) 383function --[[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
355end 386end
356 387
357function --[[rotation]] LSL.llList2Rotation(--[[list]] l,--[[integer]] index) 388function --[[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
362end 393end
363 394
364function --[[vector]] LSL.llList2Vector(--[[list]] l,--[[integer]] index) 395function --[[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
369end 400end
370 401
371function --[[integer]] LSL.llListFindList(--[[list]] l, --[[list]] l1) return 0 end; 402function --[[integer]] LSL.llListFindList(--[[list]] l, --[[list]] l1) return 0 end;
372function --[[list]] LSL.llListInsertList(--[[list]] l, --[[list]] l1,--[[integer]] index) return {} end; 403function --[[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
421end
422
373function --[[integer]] LSL.llGetListLength(--[[list]] l) 423function --[[integer]] LSL.llGetListLength(--[[list]] l)
374 return #l 424 return #l
375end 425end
376 426
377function --[[list]] LSL.llListReplaceList(--[[list]] l, --[[list]] part,--[[integer]] start,--[[integer]] eNd) return {} end; 427function --[[list]] LSL.llListReplaceList(--[[list]] l, --[[list]] part,--[[integer]] start,--[[integer]] eNd)
378function --[[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
444end
445
446function --[[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
456end
380 457
381 458
382-- Crements stuff. 459-- Crements stuff.