@@ -63,11 +63,12 @@ struct workshop_hack_data
6363typedef std::map<int32_t ,workshop_hack_data> workshops_data_t ;
6464workshops_data_t hacked_workshops;
6565
66- static void handle_update_action (color_ostream &out,df::building_workshopst*){};
66+ DEFINE_LUA_EVENT_NH_1 (onUpdateAction,df::building_workshopst*);
67+ DEFINE_LUA_EVENT_NH_2 (onSetTriggerState,df::building_workshopst*,int32_t );
6768
68- DEFINE_LUA_EVENT_1 (onUpdateAction,handle_update_action,df::building_workshopst*);
69- DFHACK_PLUGIN_LUA_EVENTS {
69+ DFHACK_PLUGIN_LUA_EVENTS{
7070 DFHACK_LUA_EVENT (onUpdateAction),
71+ DFHACK_LUA_EVENT (onSetTriggerState),
7172 DFHACK_LUA_END
7273};
7374
@@ -267,6 +268,13 @@ struct work_hook : df::building_workshopst{
267268 }
268269 INTERPOSE_NEXT (updateAction)();
269270 }
271+ DEFINE_VMETHOD_INTERPOSE (void , setTriggerState,(int32_t state))
272+ {
273+ CoreSuspendClaimer suspend;
274+ color_ostream_proxy out (Core::getInstance ().getConsole ());
275+ onSetTriggerState (out, this ,state);
276+ INTERPOSE_NEXT (setTriggerState)(state); // pretty sure default workshop has nothing related to this, but to be future proof lets do it like this
277+ }
270278 DEFINE_VMETHOD_INTERPOSE (void , drawBuilding, (uint32_t curtick,df::building_drawbuffer *db, int16_t z_offset))
271279 {
272280 INTERPOSE_NEXT (drawBuilding)(curtick,db, z_offset);
@@ -329,6 +337,7 @@ IMPLEMENT_VMETHOD_INTERPOSE(work_hook, canConnectToMachine);
329337IMPLEMENT_VMETHOD_INTERPOSE (work_hook, isUnpowered);
330338IMPLEMENT_VMETHOD_INTERPOSE (work_hook, canBeRoomSubset);
331339IMPLEMENT_VMETHOD_INTERPOSE (work_hook, updateAction);
340+ IMPLEMENT_VMETHOD_INTERPOSE (work_hook, setTriggerState);
332341IMPLEMENT_VMETHOD_INTERPOSE (work_hook, drawBuilding);
333342
334343
@@ -501,6 +510,7 @@ static void enable_hooks(bool enable)
501510 INTERPOSE_HOOK (work_hook,canBeRoomSubset).apply (enable);
502511 // update n render
503512 INTERPOSE_HOOK (work_hook,updateAction).apply (enable);
513+ INTERPOSE_HOOK (work_hook,setTriggerState).apply (enable);
504514 INTERPOSE_HOOK (work_hook,drawBuilding).apply (enable);
505515}
506516DFhackCExport command_result plugin_onstatechange (color_ostream &out, state_change_event event)
0 commit comments