Jump to content
AC Tool Forums
  • Sign Up
Sign in to follow this  
Ego

Building a Macro

Recommended Posts

The macro attached to this post is the code I will use for adding information, collecting data and modifying code for better code running.

 

This is a Sommerled to Prasad and Return Trade Run Macro. No clean up, has repeated code, a few procedures have been coded to run the same piece of code.(Mainly in the warping and map coding.)

 

The macro must be started in Sommerled Station to run properly.

Once you download and run it for 1 loop you should be able to follow the macro as it does its run.

 

First thing you need to change is in constants. Change cargo to your hold number ( i.e. 24 ) and kraken number (warp buff hotkey) to your hotkey position.

 

constants
  cargo        = 32 // Number of cargo spots in Hold.
  kraken       = 4  // Warp Buff Hotkey Position.
  //XXXXXXXXXXXX // **DO NOT CHANGE ANYTHING HERE** \\ XXXXXXXXXXXX
  Time         = 2  // Initial delay timer.
End

 

 

If you want to run more than 1 loop, you change the number 1 in the macro code which is below constants.

 

loop 1 //**Change**// Here is where loop starts for number of runs.
  call sommer      // Calls Sommerled run in and sell, buy, runout.
  call somtopras   // Sector warping to Prasad.
  call prasad      // Calls Prasad run in and sell, buy, runout.
  call prastosom   // Sector warping to Sommerled.
End

 

Read the code and you will see where in the code and how it was coded to run, sell, buy and run out from both Sommerled and Prasad.

 

Later threads to this post will show what changes I will make to the code to help the user change code to modify different areas to produce different results.  

 

 

SPS V0.1 1280.zip

Share this post


Link to post
Share on other sites

To make all changes to code, I have started to split the code into manageable chunks 'aka' macros, so each section is easier to work with.

 

As changes are made and new macros created, they will be placed in C:\EnB\SPS.

 

You must create the folders in your main drive. i.e. 'C Drive', and create a shortcut of SPS V1.0 on your desktop to run the code

 

 

 

SPS V1.0 macro in this attachment has 3 macros  included. (Just the same as the original, but split to work on easily.)

 

 

SPS V1.0.zip

 

As you look thru the included Objects macros you will see extra Object code, the Objects will be used in later updates as it is explained in future posts.

 

Objects.zip

 

 

SectorMap macro.

 

This macro ensures the sector map is small and uses Is(colour) in different positions for sector location.

 

(Each checked position is unique to the sector and has been checked to not trigger a false sector)

(The positions could be converted to an object, but not tested that idea yet)

 

The location is displayed in Game Information Window. (Can be deleted from code.)

 

SectorMap.zip

 

 

 

Map macro.

 

No change from original, just added as a stand alone macro for future code changes.

 

Map.zip

 

 

BuySell macro.

Instead of going sideways, the cursor now checks if $X, $Y is green, so the cursor can go to the cargo box and sell it. If not green go to next cargo box.

 

The cursor now goes down then sideways instead of sideways then down. (changed as code was missing the cargo box.)

 

Procedure Sub_Sell using X, Y, X2, Y2
  timestamp sell cargo // Changed sell direction to read the sell
  call moveback        // box so sell cargo.
  delay .3 sec
  loop 3               // Loops to sell all cargo hold spots.
    Set X,75
    Loop 3
      Set Y,343
      Loop 4
        delay .4 sec
        IsGreen $X, $Y            // Added to sell if green at X,Y.
          delay .1 sec
          MousePos $X, $Y
          delay .1 sec
          leftclick shift
        End
        Compute Y2 = $Y + 62
        Set Y,$Y2
      End
      Compute X2 = $X + 78
      Set X,$X2
    End
    call movecargo
  End
End

 

 

Added cargo check number to set mouse position using is[colour]. Looks for correct colour to set the mouse position,

(Looks for cargo (IsGreen) in last row or looks for cargo window (IsBlue) in last row.)

and when buying, at the correct mouse position, stops buying cargo.

 

procedure checkcargonumber   // Checks last row for cargo spot.
  Timestamp Checking Cargo Number
  set cargoslot = 0
  keys o
  delay .2 sec
  loop 3
    call movecargo
  End
  delay 1 sec
  isgreen 242, 533                // Cargo in hold.
    set cargoslot = 1
  Else
    isgreen 242, 470
      set cargoslot = 2
    Else
      isgreen 242, 406
        set cargoslot = 3
      Else
        isgreen 242, 343
          set cargoslot = 4
        End
      End
    End
  End
  isblue 242, 533                 // No cargo in hold.
    set cargoslot = 1
  Else
    isblue 242, 470
      set cargoslot = 2
    Else
      isblue 242, 406
        set cargoslot = 3
      Else
        isblue 242, 343
          set cargoslot = 4
        End
      End
    End
  End
  say /t xXx cargo slot $cargoslot     // Shows in game information window, how many slots. can be removed.
  keys o
End

 

Buy spices and weapons now uses an object detection in the vendor sell window.

 

isobject Spices at 1005, 508

 

isobject Weapons at 1052, 329

 

When correct cargo is found, fillhold code calls buying and will leftclick on the vendor sell window until isgreen triggers the break command

 

procedure fillcargo
  timestamp fill cargo position selector
  if $cargoslot = 4
    Call fillhold 242, 343
  End
  if $cargoslot = 3
    Call fillhold 242, 406
  End
  if $cargoslot = 2
    Call fillhold 242, 470
  End
  if $cargoslot = 1
    Call fillhold 242, 533
  End
End

procedure fillhold using x, y
  timestamp fill hold with trade goods
  while 1 = 1
    call buying
    delay .2 sec
    isgreen $X, $Y
      break
    End
  End
End

 

procedure buying
  if $cargo = spices
    MousePos 1175, 534
    leftclick shift
  End
  if $cargo = weapons
    MousePos 1175, 358
    leftclick shift
  End
End

 

 

buysell.zip

 

CargoCheck.zip

 

Warping macro,

 

Must have map macro in correct folder as it is used as an include macro. Or have the map code added to this macro and the include removed.

 

Warping.zip

 

CargoToStation macro.

 

This macro will be explained as it is tested. (Will not run as-is) Placed here so it is not forgotten.

Checks, using other macros, where,  what, which way to warp and then start looping. The procedures are in the process of being updated with the new code as I create it, and test it.

 

CargoToStation.zip

 

StationRun macro.

 

This is the run in and run out for Sommerled and Prasad and the starbase reset hook to place your avatar in the same position every time sbreset is called in the station.

 

Will be used in the final macro as an Include. No need to go into details about this piece of code as the features are slowly being added and will be explained later.

Could have failure protection added at a later date.

 

Added here for you to see how it works with no other commands.

stationrun.zip

 

 

Share this post


Link to post
Share on other sites

PlaceHolder.

 

SPS V2.1 macro being coded. Found a problem when at a Gate or Dock on logging into game. Too close to the Gate or Dock and the code would not enter. Created a procedure to use the W key (Closest Navigation Point) and enter, then call the SectorMapping Procedure and continue.

 

Explanation of SPS V2.0 code modifications including the full macro zipped. Needs to be unzipped and a shortcut of SPS V2.0 added to desktop.

 

SPS V2.0.zip

 

 

 

SPS V2.0 Macro.

A user needs to change the kraken constant to their Warp Buff Hotkey Position.

A user needs to change the loopnumber constant to how many runs they wish to complete.

A user may need to change ObjVar to read the Objects in the macro. (Think of ObjVar as sharpness, the higher the number the more blurry the object.)

 

constants
  kraken       = 4    //**Change**// Warp Speed Buff Hotkey Position.
  loopnumber   = 1     //**Change**// This is Number of Runs.
  //XXXXXXXXXXXX // **DO NOT CHANGE ANYTHING HERE** \\ XXXXXXXXXXXX
  cargo        = Nil
  cargoslot    = 0
  firstrun     = Yes
  sector       = Unknown
  Time         = 2
End

 

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
SetActiveWindow Earth & Beyond
delay 4 sec          // Focus EnB.
OBJVAR 3           // Colour Variance. Don't know, don't touch.

This is the object colour difference from what is recorded, the variance goes higher and lower from original by designated number.

 

Include C:\EnB\SPS\BuySell.mac
Include C:\EnB\SPS\CargoCheck.mac
Include C:\EnB\SPS\CargoToStation.mac
Include C:\EnB\SPS\Map.mac
Include C:\EnB\SPS\Objects.mac
Include C:\EnB\SPS\SectorMap.mac
Include C:\EnB\SPS\StationRun.mac
Include C:\EnB\SPS\Warping.mac

 

SPS V.2.0.zip

BuySell.zip

CargoCheck.zip

CargoToStation.zip

Map.zip

Objects.zip

SectorMap.zip

StationRun.zip

Warping.zip

Share this post


Link to post
Share on other sites

As a suggestion, you want to have the end user to modify how many times to do the run. The change the loop to use a constant and place the constant with the cargo and kraken constants. This will make it easier for the end user to make the necessary, and on the necessary, changes

 

Example:

 

constants
  cargo        = 32 // Number of cargo spots in Hold.
  kraken      = 4   // Warp Buff Hotkey Position.

  runs          = 1  // How many runs to do
  //XXXXXXXXXXXX // **DO NOT CHANGE ANYTHING HERE** \\ XXXXXXXXXXXX
  Time         = 2  // Initial delay timer.
End

 

loop $runs // Here is where loop starts for number of runs.
  call sommer      // Calls Sommerled run in and sell, buy, runout.
  call somtopras   // Sector warping to Prasad.
  call prasad      // Calls Prasad run in and sell, buy, runout.
  call prastosom   // Sector warping to Sommerled.
End

Share this post


Link to post
Share on other sites

That's coming as I make changes to the macro in each post as the code is condensed and modified to change how things happen. Was up till 0120 checking the code runs as intended each time I added something.

Fell asleep at keyboard. Bad wife faction.

 

a snippet:

 

constants
  kraken       = 4
  loopnumber   = 1
  //XXXXXXXXXXXX // **DO NOT CHANGE ANYTHING HERE** \\ XXXXXXXXXXXX
  cargo        = Nil
  cargoslot    = 0
  sector       = unknown
  Time         = 2
End

 

As you can see there will be some changes as I go thru each section as I create them. I have a working SPS macro that checks position, what cargo is in hold, which way to warp

and automatically fills and sells cargo without the user inputting how may cargo spaces they hold.

 

This macro does not auto restart script if there is a problem. That might be added later as my terminal run macro has it added, One step at a time for a new macro user to code their own.

Share this post


Link to post
Share on other sites

--- snip ---

 

Was up till 0120 checking the code runs as intended each time I added something.

Fell asleep at keyboard. Bad wife faction.

 

--- snip ---

shame on you!!! :o :o

 

50 lashes with a wet noodle, a brogue of flowers, and no computer for two days.

 

 

Anyways, i hear you there. I've been in the dog house too.

Share this post


Link to post
Share on other sites

I'm having some issues getting this macro to run it seems they moved the trade button on the vendors or is there a setting that I am missing in the dialog options? it is missing the trade found bubble in the steps every time and just exits the station without purchasing tradegoods.

Share this post


Link to post
Share on other sites

1280 x 800 windowed mode.

 

Tested, code works, but that could be that I modified some code due to some errors, think your glitch was one. Didn't find name sort and price sort stopped the code from getting jobs.

 

Try this macro.

 

SPS 3.1.zip

 

 

Just ran a few loops, worked fine. I changed the name sort to price sort and the code changed it back and bought the correct cargo to go to Prasad. Think that's all. Any problems, let me know.

Share this post


Link to post
Share on other sites

Found the problem with not clicking on the trade bubble. Need the change the code in buysell macro to the lines below.

 

  delay 2 sec
  leftclick
  delay 3 sec
  timestamp look for trade button
  isobject Trade at 257, 709  // If trade button, click on it.

 

Need to change the trade object data in objects macro to the code below.

 

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Object trade  //  257, 709 Size: 8, 8  width x height
  254=0,0|254=0,2|254=0,4|254=0,6
  77=2,0|65=2,2|51=2,4
  254=6,2
  51=8,4|51=8,6|57=8,8
End
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

I didn't reload the zip file, this will see who actually is attempting to learn how to code macros.

Share this post


Link to post
Share on other sites

Found the problem with not clicking on the trade bubble. Need the change the code in buysell macro to the lines below.

 

... snip ...

 

I didn't reload the zip file, this will see who actually is attempting to learn how to code macros.

 

that sounds very reasonable to me.

Share this post


Link to post
Share on other sites

Heh got caught out by my own coding, forgot to add it to my sommer code and ran it 2 days ago, pulled my hair out till I watched and realised it wasn't opening the trade bubble.

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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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