MODULE: SpinLock v1.01

Started by Snake Blisken, Thu 01/12/2005 13:32:13

Previous topic - Next topic

Snake Blisken

Please take a look at my first module and let me know what you think about it. Test it to death if you feel up to it.

It is a spinning combination lock, like you might find on a school or gym locker. Any helpful advice is greatly appreciated, no matter how small you might think it is.

2 Dec 2005: v1.01   Removed combination configuration from InitCombo. You
//            will now need to call SetCombo(). Also removed Completion().
//            You will now need to test SpinRight to see if the correct
//            combo has been called. Renamed InitCombo to InitLock and
//            changed the module and struct from SpinCombo to SpinLock.
//            Removed all variables from the struct and put them in the
//            main module.
//            Many thanks to strazer for all the suggestions!

Download here (Requires AGS v2.71!)

Please let me know in advance if you decide to mirror the file somewhere.

Thanks
Snake Blisken
Thanks,
Snake Blisken

strazer

#1
1.) Put the first brace directly after the struct title, otherwise SpinCombo doesn't auto-complete:
  struct SpinCombo {
instead of
  struct SpinCombo
  {

2.) Why put variables in the struct at all? Just leave them in the main module script if they won't be accessed outside of it.

3.) According to the readme, "You will need to adjust the first three variables in SpinCombo.InitCombo()".
The user shouldn't have to edit the module. What if you release an updated version? Then the user would have to edit it again, or worse, forgets that he has to.
You should require the user to call SpinCombo.SetCombo from in his script beforehand and he shouldn't have to delete the three lines from the module. Just raise an error if no combination was given.

The same applies to SpinCombo.Completion(). The user shouldn't have to put what happens when the lock was solved into the module.
I'm not sure how to best do this since you can't call functions from the global script in a module. How about the user having to put it like this into the GUI click event:

Code: ags

  // script for GUI button

  if (SpinCombo.SpinLeft() == true) {
    ComboLockFiguredOut(); // call function defined earlier in global script
    // or put completion code here, but then you would have to duplicate it for the other spin direction
  }

(and same for spin right GUI button)

SpinCombo.SpinLeft and .SpinRight would spin the lock and then return true if the combination was solved and false if not.

4.) For consistency's sake, decide on a name: Name the zip SpinCombo as well or (what I'd prefer) name the struct and module SpinLock.

Snake Blisken

#2
Thanks strazer for all the advice. I think I changed everything you suggested. And not because I am a follower, but because they were really good suggestions! :)

QuoteSpinCombo.SpinLeft and .SpinRight would spin the lock and then return true if the combination was solved and false if not.

Well, the combination can't be solved by turning left, so you only need to test on a right spin. Thanks again for all of your help. Please let me know if there is anything else I can do to make this better.
Thanks,
Snake Blisken

strazer


SMF spam blocked by CleanTalk