Page 1 of 1

MM2 specific questions

Posted: Mon Oct 27, 2014 6:55 pm
by lisa
ok so with MM2 the suggested usage is to not use rests and to have the script going through the micro.main() constantly, there are states that can be implemented so you don't have 100 checks in the main loop and it can keep doing the code it should be doing. What this means for me though is that if you don't use states then there will be a lot variables to help tell MM what it should be doing.

example in the archeage mount script.
local running = false;

In my harvesting script
local running = false;
local chatpause = false


So now to the actual question, when troubleshooting you generally have in lots of print this and print that, is there an easy way to print the variables (names and values)
So if the script errors it might print
error line 54, blah blah
running false
chatpause true

Or am I just dreaming?

Re: MM2 specific questions

Posted: Mon Oct 27, 2014 9:08 pm
by rock5
In regards to states, I think I came up with an easy way to implement it for simpler functions when I did my splitter addon. Example.

Code: Select all

function example(elapsedtime)
   if wait > 0 then
      wait = wait - elapsedtime
   elseif step == 1 then
      -- Do first thing
      step = 2
      wait = 2 -- wait 2 before moving on to next step
   elseif step == 2 then
      -- Do second thing
      if condition then
         step = 1 -- repeat steps
      else
         step = 3
      end
      wait = 3
   elseif step == 3
      -- last step. clean up.
      step = nil
      wait = 0
   end
end
I find this an easy way to control the flow. What do you think? Does that make sense?

Re: MM2 specific questions

Posted: Tue Oct 28, 2014 12:57 am
by BlubBlab
I'm not sure what the question is. I had implemented a framework for the states of MM2 but yeah when you use fix vars instead you need to make a maze of if ...then which means you need for every new state you add, you also need to add a new var into the maze.

So for every new state you need to add a new print, or you can made everything dynamic and use an array which is pretty much what I did. By the way my framework has also an default wait/rest state which can be used.

Re: MM2 specific questions

Posted: Wed Oct 29, 2014 3:14 am
by Administrator
I think you should split each set of logic into separate classes where it makes sense (ie. states), then have those classes each have their own debug reporting function that would return a string of relevant data. Now, you could call your classe's functions in a protected environment (pcall()) and rely on the debug report callback to extract useful info when there is an error. This is simple, effective, and gives you full control over what information is going to be displayed when something bad happens.

I haven't really made any scripts worth showing off, but what I've found to be effective is just to have a few re-usable variables (ie, state, timer, whatever else) to control the flow to separate functions or classes. Pretty similar to what rock5 posted, actually.