ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.18k stars 515 forks source link

why is get_type return userdata? #1563

Open mumin1616 opened 9 months ago

mumin1616 commented 9 months ago

the following function return userdata:

function AD() local out = {} for i = 1, #CLOSE, 1 do
hi=high[i]; lo=low[i]; cl=close[i]; sum=(cl-lo)-(hi-cl); if hi==lo then sum=0.0; else sum=(sum/(hi-lo))*VOLUME[i]; end if i>1 then sum=sum+out[i-1]; end

out[i]=sum;

end return out end

the following function return table:

function SMA(source, period) if type(source) == type(1) then if source == 0 then source = CLOSE elseif source == 1 then source = OPEN elseif source == 2 then source = HIGH elseif source == 3 then source = LOW elseif source == 4 then source = MEDIAN elseif source == 5 then source = TYPICAL elseif source == 6 then source = WEIGHTED end end local sum = SUM(source, period) local out = {} for j = 1, #sum, 1 do out[j] = sum[j] / period end return out end

why is first function return userdata? i want table, process is easy: //c++ auto ret_val = lua["blabla"].get<std::vector>();

How do I process userdata?