Jump to content
AC Tool Forums
  • Sign Up
Ego

EnB Macro Help

Recommended Posts

Any questions related to Earth and Beyond macros can be posted here.

Any requests for coding macros goes in the bin on your desktop.

Share this post


Link to post
Share on other sites

unlocktester.zip

Need some advice on condensing the Numbers Procedure, tried a few ideas but had no luck.

I might need to rewrite the code but I have put so much time into it I really don't want to drop it.

This is not the finished macro, just the unlocking part. Once this part works I will be adding the code to open each game window and add name, password and avatar position to load the avatars.

Share this post


Link to post
Share on other sites

You repeat a lot of code in those if statements. Don't duplicate code, it will save lines. 
Here are two ways. Though I could probably come up with even more. I'd personally use Lists as the solution. Clean, Simple, Straight Forward. 

Using lists, this code will not work as is it's more sudo code as list[index+1] is not valid syntax sadly.  This is just to give you an idea (don't forget to account for max list size, {loopNo} + 1 can give you an index out of bounds error)

constructs
  layouts = List
  accounts = List
  avatars = List
  leftLocations = List
  topLocations = List
end
procedure setValues
  listAdd layouts, 110
  // ... add others
  listAdd accounts, 140
  // ... add others
  listAdd avatars, 1xxxxx
  // ... add others
  listAdd leftLocations, 0
  // ... add others
  listAdd topLocations, 0
end
// list way
procedure numbers
  loop $number
    if $number > 1
      set layout[{loopNo}] = layout[{loopNo} + 1]
      set accounts[{loopNo}] = accounts[{loopNo} + 1]
      set avatars[{loopNo}] = avatars[{loopNo} + 1]
      set leftLocations[{loopNo}] = leftLocations[{loopNo} + 1]
      set topLocations[{loopNo}] = topLocations[{loopNo} + 1]
    end
    call layout
    call accountname
  end
end


Simpler if statement way .. this is untested, I am not sure if it will work 100% but again just to give you an idea. 

procedure numbers
  loop $number
    If $number >= 1
      set layout = $layout1
      set AccountName = $AccountName1
      set avatarname = $avatar1name
      set left = $left1
      set top = $top1
    end
    
    If $number >= 2
      set layout = $layout2
      set AccountName1 = $AccountName2
      set avatar1name = $avatar2name
      set left1 = $left2
      set top1 = $top2
    End
    
    If $number >= 3
      set layout = $layout3
      set AccountName2 = $AccountName3
      set avatar2name = $avatar3name
      set left2 = $left3
      set top2 = $top3
    End
    
    If $number >= 4
      set layout = $layout4
      set AccountName3 = $AccountName4
      set avatar3name = $avatar4name
      set left3 = $left4
      set top3 = $top4
    End
    
    If $number >= 5
      set layout = $layout5
      set AccountName4 = $AccountName5
      set avatar4name = $avatar5name
      set left4 = $left5
      set top4 = $top5
    End
    
    If $number >= 6
      set layout = $layout6
      set AccountName5 = $AccountName6
      set avatar5name = $avatar6name
      set left5 = $left6
      set top5 = $top6
    End
    call layout
    call accountname
  end
end

 

Share this post


Link to post
Share on other sites

Used the if statement exactly as is, it worked with no changes, thanks a lot mysticdrew, cut out a few lines :)

Now working out why the names will not reset back to what is in the constants, guessing I might need to do a setconstant command in my code after the procedures log in, that's where I get the same name trying to load the same avatar and position into the window on all the accounts and fails. I will find it, has to be something simple.

When I separate the code and I created another macro to load the avatars, it works, but when I tried to combine them it failed, that's why i think I need to find where the constants are needing a reset (setconstant) and I can build a full login and group and form. (atm they are all separate)

Again thanks for the help.

 

Share this post


Link to post
Share on other sites
14 hours ago, Ego said:

Used the if statement exactly as is, it worked with no changes, thanks a lot mysticdrew, cut out a few lines :)

Now working out why the names will not reset back to what is in the constants, guessing I might need to do a setconstant command in my code after the procedures log in, that's where I get the same name trying to load the same avatar and position into the window on all the accounts and fails. I will find it, has to be something simple.

When I separate the code and I created another macro to load the avatars, it works, but when I tried to combine them it failed, that's why i think I need to find where the constants are needing a reset (setconstant) and I can build a full login and group and form. (atm they are all separate)

Again thanks for the help.

 

Ego, is this the same code that you are using similar to what was in the code that you had sent to me to try and convert to Divide?

Could you post the code from the Starting of the Clients to the toon selection.

Share this post


Link to post
Share on other sites

Added mysticdrews suggestion, but, had to change the layout activation as the multiclient window was being double clicked now and then.

Moved some code around and now only clicks layout once after reading how many avatars in $number.

Now working on my other problem about the wrong avatar being loaded when I combine login and avatar.

6 Toon Login V1.1.mac

Share this post


Link to post
Share on other sites

After looking at layout and how the constants are set, I added the set avatarxxx  code after the end statement to make the constants the same as what is in the constants at the beginning of the macro.

This is done as the "timestamp $avatar1name is avatarname at finish of unlock." was Xsix which created havoc when the next procedure started.

Is there a way to use what is in the constants in the beginning of the macro? or the constants need resetting as I have indicated?

 

Part of the layout procedure.

If $number >= 6
      set AccountName5 = $AccountName6
      set avatar5name = $avatar6name
      set left5 = $left6
      set top5 = $top6
    End
    call accountname
  End
  set Avatar1name  = Xone      // Name of 1st Avatar.
  set Avatar2name  = Xtwo      // Name of 2nd Avatar.
  set Avatar3name  = Xthree    // Name of 3rd Avatar.
  set Avatar4name  = Xfour     // Name of 4th Avatar.
  set Avatar5name  = Xfive     // Name of 5th Avatar.
  set Avatar6name  = Xsix      // Name of 6th Avatar.

  timestamp $avatar1name is avatarname at finish of unlock.

 

Share this post


Link to post
Share on other sites

Well, here is a completely working version of the 6 Toon Login. At the moment I have not had the chance to look at the 6 Toon Avatar script yet.

But, with this version of the login, you will not have any issues with the unlocking, loading, and setting up each game client window. I was also able to reduce the overall lines of code too.

 

 

6 Toon Login V1.2.mac

Share this post


Link to post
Share on other sites

Okay, after looking at the code for all of the remaining scripts. I was able to take care of them. And I have combined them all together into one script file. There was alot of repeat and unnecessary code in all the remaining scripts. I was able to optimize it all. And the whole thing is now a total of 397 lines of code. That is way less than what you had before.

So, here is your new All-in-one 6 Toon Login script.

Now, just to tell you. Although I was able to test the Login and Avatar selecting code. I was not able to test any of the remaining code. Its just that I do not have any toons to be able to group and get into a formation. But, I do believe the code should work as is. If not let me know.

 

 

6 Toon Login Complete V1.mac

Share this post


Link to post
Share on other sites

Ego, one last thing. About your code in your scripts. You seem to have the habit of creating constants that has the exact same name as a procedure. This is a very big no no, in any programing. What you need to start doing is naming your procedures and your constants for what they really are for or to do.

Such as:

For that procedures you have
Windows
WindowsUnlock
Start
loadavatar
Group
formation
Avatar
Layout
Accountname
Getposition

And then you had serveral constants that had the same name of one of the above:
accountname
avatar

just to name a few off the top of my head.

The names for the procedures should be
Windows = CloseWindows or CloseOpenWindows
WindowsUnlock = SetupUnlocker
Start = OpenClients
Avatar = SelectAvatar

and the constants should be something similar. such as Avatarname1 which is for the position of the avatar should really be AvatarPos1.

I hope you get my drift. The reason for this is that the code that you wright is a lot easier for you to read. And not to mention a lot easier for others to read and understand what you are doing. And should start putting comments in your code describing what a specific line, or section, of code does or is for. This does wonders in helping others to know what you are trying to accomplice.

 

And for the sake of trying to make your script work, and work better, you might want to start creating procedures that use constants of their own. such as the GetPosition procedure. buy using Procedures ... using ... ... ... end you will end up creating less constants in your constants sections. You will find that I changed a couple of your procedures to be that way. And eliminating quite a few unnecessary constants.

 

Share this post


Link to post
Share on other sites

Think I understand what you are trying to say. Looking at the code you posted I can see what you mean.

Will rewrite my Sommer macro to do as you suggested. Bound to find ways to shorten it :)

Thanks Wabbit.

Share this post


Link to post
Share on other sites

Need to add avatarpos = 0 in the second constant section, and it runs. I just need to slow down some timers as it's too fast and clicking before screens are loaded, I expected that.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and to our Privacy Policy.