kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

How do I use the .any expression?

Duncan-Alexander-Coutts opened this issue ยท 0 comments

commented

Hi, I am new to KRPC.

I want to use a custom event to find out if any engine has run out of fuel. I have been trying to use the .any function but not having much luck.

The documentation for .any shows that a list is required for the first param which I think I have correct and the second param is an function with type Expression. How can I define a function that gets called correctly with each item of the list given as the first param of the .any call?

all_engines` = connection.get_call(getattr, vessel.parts, 'engines')

expr = connection.krpc.Expression.any(
    connection.krpc.Expression.call(all_engines),
    connection.krpc.Expression.function(**not_sure_what_goes_here**, my_function)
)