| 172 | |
| 173 | /// |
| 174 | void unicast(ScriptWorld &sw |
| 175 | , const char *function_name |
| 176 | , ScriptId script_inst |
| 177 | , const ArgType::Enum *arg_types |
| 178 | , const Arg *args |
| 179 | , u32 num_args |
| 180 | ) |
| 181 | { |
| 182 | if (sw._disable_callbacks) |
| 183 | return; |
| 184 | |
| 185 | LuaStack stack(sw._lua_environment->L); |
| 186 | |
| 187 | lua_rawgeti(stack.L, LUA_REGISTRYINDEX, sw._script[sw._data[script_inst.i].script_i].module_ref); |
| 188 | lua_getfield(stack.L, -1, function_name); |
| 189 | |
| 190 | if (lua_isnil(stack.L, -1)) { |
| 191 | stack.pop(2); |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | stack.push_args(arg_types, args, num_args); |
| 196 | |
| 197 | int status = sw._lua_environment->call(num_args, 0); |
| 198 | if (status != LUA_OK) { |
| 199 | report(stack.L, status); |
| 200 | device()->pause(); |
| 201 | } |
| 202 | stack.pop(1); |
| 203 | } |
| 204 | |
| 205 | void units_with_script(ScriptWorld &sw, Array<Index> &index, const UnitId *units, u32 num) |
| 206 | { |
no test coverage detected