diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index 86163b1..8b8d292 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -407,11 +407,22 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- endif -%} {%- if type is instanceof('\\mtgArrType') -%} + var _arr_type = (ArrayTypeSymbol){{value}}.type; + int _native_before_count = 0; + {%- if type == 'any[]'-%} {{native}} = ValList.New(frm.vm); + {%~ else ~%} + try + { + _native_before_count = {{native}}.Count; + } + catch(NullReferenceException) + { + {{native}} = new(); + } {%~ endif -%} - var _arr_type = (ArrayTypeSymbol){{value}}.type; - int _native_before_count = {{native}}.Count; + for(int i=0;i<_arr_type.ArrCount({{value}});++i) { var _arr_item = _arr_type.ArrGetAt({{value}}, i);