How to call another LUA script with an ARRAY parameter?

bakka
Contributor

I have a series of interdependant LUA scripts, that also can be called individually. They take an array as parameter, and I need to pass the array down the chain when calling the scripts. 

I have tried many different things, but keep getting the error: "43000:"import function: parameters of type userdata not supported" caught in script "MASTER_SCRIPT" at line 2" (adjusted to below example).

It I output the arrayParm it prints NULL - consistent with the "userdata" error message.

So how do I speficy the arrayParm in the import-statement call of the script_to_call.

CREATE OR REPLACE SCRIPT script_to_call (parm1, ARRAY arrayParm) AS

output('Success')

for i=1, #arrayParm do

    output('Looping')

end

CREATE OR REPLACE SCRIPT master_script(parm1, ARRAY arrayParm) AS

 import('SCRIPT_TO_CALL', 'test', parm1, ???arrayParm??)

 

 

1 ACCEPTED SOLUTION

mwellbro
Xpert

Hi @bakka ,

I tried this and it ran through, but I probably didn´t yet understand the issue:

CREATE OR REPLACE SCRIPT script_to_call(parm1, ARRAY arrayParm) AS

output('Success')

for q=1, #arrayParm do

    output('Looping')

end
/


CREATE OR REPLACE SCRIPT master_script(parm1, ARRAY arrayParm) AS

 import('SCRIPT_TO_CALL', 'test', parm1, arrayParm)

output('done')
/

execute script master_script(1,array('test1','test2','test3')) with output;

mwellbro_0-1611912885351.png

 

View solution in original post

2 REPLIES 2

bakka
Contributor

I actually tried this but got the user data error. But your example works, so I must be doing something else wrong. Thanks

mwellbro
Xpert

Hi @bakka ,

I tried this and it ran through, but I probably didn´t yet understand the issue:

CREATE OR REPLACE SCRIPT script_to_call(parm1, ARRAY arrayParm) AS

output('Success')

for q=1, #arrayParm do

    output('Looping')

end
/


CREATE OR REPLACE SCRIPT master_script(parm1, ARRAY arrayParm) AS

 import('SCRIPT_TO_CALL', 'test', parm1, arrayParm)

output('done')
/

execute script master_script(1,array('test1','test2','test3')) with output;

mwellbro_0-1611912885351.png

 

View solution in original post