I... don't think I understand you.
Here, I'll post a simplified version of my machine (not the 600 lines, as there's a lot of repetetive code I couldn't avoid, but it is still some good 200 lines... perhaps they'll help me make my point):
Machine "Fixing_Devices"
State Setup
Rule event in
:action
something_is_inside:=1; //this is used to check if all the devices in a given set (military, non-military) are done or not.
if(m.first_time=0,
/*Here I divided the weapons, no use to show this...*/
m.first_time:=1;
LocalEvent(MainMenu);
);
:end
END
Rule event Selected
Condition E.ship=M.ac&m.Dialog_running!=1&Timer_on=0
:action
LocalEvent(mainmenu);
:end
END
Rule event MainMenu
:action
M.Dialog_running:=1;
ChooseFirst(
m.No_More_N_Devs = 1 & m.No_More_M_Devs = 1 & No_More_Devs = 0,
No_more_devs:=1;
Dialog("No_More_Devs",0,0); //this dialog is show in case there're no more devices to fix
, m.No_More_N_Devs = 1 & no_more_devs = 0,
Dialog("First_Choice_military",0,0); //this is the tree of non-military is all done
, m.No_More_M_Devs = 1 & no_more_devs = 0,
Dialog("First_Choice_no_military",0,0); //idem but with the military done
, m.No_More_N_Devs = 0 & m.No_More_M_Devs = 0,
Dialog("First_Choice",0,0); //when they're all incomplete.
);
:end
END
Rule event Cycle_normal
:action
m.military_cycle:=0;
ChooseFirst(
m.eng = 1 | m.eng_sec =1 & m.nav = 1 & m.sens = 1 & m.pgen = 1 & m.hyp = 0 & m.hyp_cycle = 0,
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_hyp",0,0); //this is the ultimate goal, repair the hyperdrive, and to do so you have to fix all of the above (engine, nav, sensors and pgen)
M.Dialog_running:=1;
, m.eng = 0 & m.eng_cycle = 0,
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_eng",0,0);
M.Dialog_running:=1;
/*...*/
, m.pgen = 0 & m.pgen_cycle = 0, //this is the part I'm interested in, the power generator
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_pgen",0,0);
M.Dialog_running:=1;
/*...*/
, m.blank = 0, //in case the player didn't choose anything
Deletependingdialogs(1);
M.Dialog_running:=1;
if(something_is_inside=1,
Dialog("blank_choice",0,0);
,
Dialog("No_More_N_Devs",0,0);
m.No_More_N_Devs:=1;
);
);
:end
END
Rule event Cycle_military
:action
m.military_cycle:=1;
ChooseFirst(
/* Pretty much the same as above, but with weapons and weapons generators */
, m.blank = 0,
Deletependingdialogs(1);
M.Dialog_running:=1;
if(something_is_inside=1,
Dialog("blank_choice",0,0);
,
Dialog("No_More_M_Devs",0,0);
m.No_More_M_Devs:=1;
);
);
:end
END
Rule event Re_Start
:action
LocalEvent(blanc);
LocalEvent(MainMenu);
:end
END
Rule event Blanc
:action
something_is_inside:=1;
M.Dialog_running:=0;
m.eng_cycle:=0;
m.pgen_cycle:=0; //these are the cycle variables, and in here we set them back to 0, as the whole cycle is re-starting.
:end
END
/* and all of these are the output of the player choosing to fix these devices */
Rule event eng
:action
SelectDevices(1, m.ac, s.this:devtype=#eng_b304);
Execlist(1,dev:=s.this);
M.eng:=1;
Debug("e.dev is", e.dev);
ChangeState(countdown, dev:=dev; E.time:=110);
:end
END
Rule event eng_sec
:action
SelectDevices(1, m.ac, s.this:devtype=#eng_b304); //#eng_b304_sec);
Execlist(1, dev:=s.this);
m.eng_sec:=1;
ChangeState(countdown, dev:=dev; E.time:=55;);
:end
END
/*...*/
Rule event pgen ///this is the polemic rule, still not working...
:action
E.time:=250;
SelectDevices(1, m.ac, InSet(s.this,66)| InSet(s.this,42));
Execlist(1,
debug("1",s.this);
Debug("----------------The devices are:", s.this);
ChangeState(countdown, dev:=s.this; E.time:=p.time);
);
:end
END
/*this is the cycle part, the one that enables the rolling of the dialog-options. Basically this works this way, when a dialog is called in the "cycle_***" rule, three options appear: "fix it","next" and "nothing right now", the fix it relates to the above rules, the next to the ones below and the nothing right now to the "blanc" rule. */
/*...*/
Rule event eng_Cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.eng_cycle:=1;
LocalEvent(Cycle_normal);
:end
END
Rule event eng_sec_cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.eng_sec_cycle:=1;
LocalEvent(Cycle_normal);
:end
END
/*...*/
Rule event pgen_cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.pgen_cycle:=1;
LocalEvent(Cycle_normal);
:end
END
Rule event Fix_cycle //this event is only fired if the dialog with the dialog with the options times out.
:action
if(m.military_cycle = 1,
Debug(m.military_cycle);
Delay(0,0.1,LocalEvent(cycle_military);,0);
,
Debug(m.military_cycle);
Delay(0,0.1,LocalEvent(cycle_normal);,0);
);
:end
END
END
State Countdown
Rule event in
:action
//in here we reset the cycle of all devices
M.Dialog_running:=0;
m.eng_cycle:=0;
/*...*/
m.pgen_cycle:=0;
/*...*/
StartCountDown(e.time, Repair);
m.fixing:=1;
Debug("dev is",dev);
:end
END
Rule event Repair
:action
Debug("event Repair", dev);
if(dev!=0 & engineering = 0,
EnableDevice(dev,1);
Debug("repairing", dev);
,
if( engineering = 1,
m.engineering:=1;
);
);
m.fixing:=0;
ChangeState(setup,0);
:end
END
END
END