LlListReplaceList/ko

From Second Life Wiki
< LlListReplaceList
Revision as of 00:21, 12 April 2009 by Nanjido Oh (talk | contribs) (New page: {{LSL_Function/negative index/ko|true|start|end}}{{LSL_Function/ko |func_id=296|func_sleep=0.0|func_energy=10.0 |func=llListReplaceList|return_type=list |p1_type=list|p1_name=dest|p1_desc=...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

설명

함수: list llListReplaceList( list dest, list src, integer start, integer end );
296 함수ID
0.0 지연
10.0 에너지

반환되는 값은 목록 dest의 색인 start에서 end까지가 src로 삽입 치환된 새로운 목록.

• list dest destination
• list src source
• integer start start 색인
• integer end end 색인

start & end음의 색인을 지원한다.

명세

색인
처음 0 -length
마지막 length - 1 -1

우선 임의의 음수 색인은 양수 색인으로 먼저 생각한다

  • 만약 start <= end이면 적용 범위는 start에서 시작하여 end에서 끝난다.[start, end]
  • 만약 start > end이면 적용 범위는 0에서 시작하여 end를 지난 뒤 다시start에서 출발하여 -1로 간다. [0, end] + [start, -1]

(마지막 색인보다 큰) 전체 길이 이전의 양의 색인, 또는 (첫 색인보다 전방에 위치한) 시작점 이전의 음의 색인 만이 유효하다. 효과는 예측가능하며 항목들은 어딘가에 실제로 존재하는 것 처럼 다루어지지만, 실은 출력 이전에 모두 삭제된다.

더 자세한 정보는 음의 색인을 참조.

If start is past the end of dest, then src is appended to dest, it will not add null entries. To avoid this, create empty elements in the list first. A similar outcome occurs when using negative indexes.

주의

  • Just calling the function will not update the variable. You must store it (unless of course you are planning to act on the results straightway.)
• Bad: llListReplaceList(a, ["c"], 2, 2)
• Good: a = llListReplaceList(a, ["c"], 2, 2)
  • If you are storing to the same list, it can be more memory effective to clear the list before you store.
• Good: a = llListReplaceList(a, ["c"], 2, 2)
• Better: a = llListReplaceList((a = []) + a, ["c"], 2, 2)

예제

<lsl>default {

   state_entry()
   {
       list a = ["a", "b", "e", "d"];
       list b = llListReplaceList(a, ["c"], 2, 2);//replace the range starting and ending at index 2 with ["c"] and store it into b
       llOwnerSay("\""+llList2CSV(a) + "\"  ->  \"" + llList2CSV(b)+"\"");//display the change
       //Will say: "a, b, e, d"  ->  "a, b, c, d"
   }

}</lsl>

기록

To be clear, the list you are replacing in doesn't have to actually be a list of many elements. It can be a single item that you make into a single element list just by placing square brackets around it.

<lsl>list TargetList = ["a", "b", "c", "z", "e"]; list InsertList = ["d"];</lsl>

To act on a single element in a list, just quote its place in the list as both start and end. For instance, 0, 0 would act only on the first element in the list; 7,7 would act only on the 8th element.

For a function that will operate as llListReplaceList does, but work on strided lists, see ListStridedUpdate.

함께 보기

함수

• llDeleteSubList
• llListInsertList
• llList2List

문서

•  Negative_Index

상세 기록

이 글이 유용하지 않으세요? LSL Wiki의 관련항목이 도움을 줄 수 있을 지도 모릅니다.