Foreverperson 發表於 2017-1-23 16:22:33

function中引用array該如何呼叫

本帖最後由 Foreverperson 於 2017-1-23 08:45 PM 編輯

大家好,prontera.gat,150,178,4      script      test      120,{      


setarray @copyarray,1,6,7,8,0,0;

set @t,4;


callfunc "arraytest","@copyarray";

end;

}





function      script      arraytest      {


setarray @replace_array,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;


for (set @o,0;@o<4;set @o,@o+1)
{
set @replace_array[@o],getd("getarg(0)"+"["+@o+"]");
announce ""+@replace_array[@o]+"",15;
}


}想問 function如何在引入array的情況下將其呼叫出來,就是說getarg(0) 如何讓他顯示為變數名稱,
或者有其他方法將 @ copyarray在函數中複製到 @ replace_array

謝謝各位大大!



o03126 發表於 2017-1-23 19:16:52

getelementofarray(getarg(0),@o);

Foreverperson 發表於 2017-1-23 20:44:38

o03126 發表於 2017-1-23 07:16 PM static/image/common/back.gif
getelementofarray(getarg(0),@o);

太感謝您的幫忙,對許多語法很不熟悉

問題已解決!

louis8604031 發表於 2017-1-23 20:52:58

prontera,149,181,4        script        Array        1002,{
        setarray .@copyarray,1,6,7,8,0,1;
        for(set .@i,0;.@i<getarraysize(.@copyarray);set .@i,.@i+1)mes ".@copyarray["+.@i+"] = "+.@copyarray[.@i];
        mes "---------------------------";
        callfunc ("TestOkay",.@copyarray);
       
        close;
}

function        script        TestOkay        {
        copyarray .@replace_array,getarg(0),getarraysize(getarg(0));
        for(set .@i,0;.@i<getarraysize(.@replace_array);set .@i,.@i+1)mes ".@replace_array["+.@i+"] = "+.@replace_array[.@i];
        return;
}


頁: [1]
查看完整版本: function中引用array該如何呼叫