본문 바로가기
  • fishing...
  • eating...
MISCELLANEOUSNESS

이런 빌어먹을.. 루아에서 왜 배열을 저장 안되는 문제.

by 회색뿔 2010. 8. 15.


매일 하루에 10번씩은 삽을 푸는 거 같은..ㅠ_ ㅠ


대충요약 해보면, 오브젝트와 숫자가 저장하려고 한다면, 명확하게 지정하여야만한다.
아래는 Array.SetValue를 이용하여 배열에 넣어주는 것이네요.

결국엔 LUA에 맞게 바꿔서 써야 된다는 내용이내요.

note that you can only initialize values in this simple way if you are dealing with objects and not numbers. Then you have to use Array.SetValue explicitly.
> d = Double[4]
> d[0] = 1.0
System.InvalidCastException: Unable to cast object of type
'System.Double[]' to type 'System.Object[]'.
> d:SetValue(0,1.0)

There are no implicit conversions of Lua tables into .NET types, but it is easy to do manually. Here is a useful function for creating an array of doubles from a table:
function make_double_array (tbl)
    local arr = Double[#tbl]
    for i,v in ipairs(tbl) do
        arr:SetValue(v,i-1)
    end
    return arr
end
결국은 오늘도 삽질 했다.ㅠ_ㅠ


'MISCELLANEOUSNESS' 카테고리의 다른 글

자바 Homework 파일..  (0) 2010.08.16
Eclipse + SVN 설치 방법  (0) 2010.08.14
강의 교재.  (0) 2010.08.14