| 686 | } |
| 687 | |
| 688 | void Plugin::index_lua(DFLibrary *lib) |
| 689 | { |
| 690 | if (auto cmdlist = (CommandReg*)LookupPlugin(lib, "plugin_lua_commands")) |
| 691 | { |
| 692 | for (; cmdlist->name; ++cmdlist) |
| 693 | { |
| 694 | auto &cmd = lua_commands[cmdlist->name]; |
| 695 | if (!cmd) cmd = new LuaCommand(this,cmdlist->name); |
| 696 | cmd->command = cmdlist->command; |
| 697 | } |
| 698 | } |
| 699 | if (auto funlist = (FunctionReg*)LookupPlugin(lib, "plugin_lua_functions")) |
| 700 | { |
| 701 | for (; funlist->name; ++funlist) |
| 702 | { |
| 703 | auto &cmd = lua_functions[funlist->name]; |
| 704 | if (!cmd) cmd = new LuaFunction(this,funlist->name); |
| 705 | cmd->identity = funlist->identity; |
| 706 | } |
| 707 | } |
| 708 | if (auto evlist = (EventReg*)LookupPlugin(lib, "plugin_lua_events")) |
| 709 | { |
| 710 | for (; evlist->name; ++evlist) |
| 711 | { |
| 712 | auto &cmd = lua_events[evlist->name]; |
| 713 | if (!cmd) cmd = new LuaEvent(this,evlist->name); |
| 714 | cmd->handler.identity = evlist->event->get_handler(); |
| 715 | cmd->event = evlist->event; |
| 716 | if (cmd->active) |
| 717 | { |
| 718 | cmd->event->bind(DFHack::Core::getInstance().getLuaState(), cmd); |
| 719 | if (cmd->count > 0) |
| 720 | cmd->event->on_count_changed(cmd->count, 0); |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | void Plugin::reset_lua() |
| 727 | { |
nothing calls this directly
no test coverage detected