Jump to content


Photo

Building a Macro


  • Please log in to reply
8 replies to this topic

#1 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 02 January 2019 - 11:55 PM

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.  

 

Attached Files


Ego is not a dirty word


#2 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 03 January 2019 - 12:29 AM

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.)

 

 

Attached File  SPS V1.0.zip   4.41KB   2 downloads

 

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.

 

Attached File  Objects.zip   630bytes   3 downloads

 

 

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.)

 

Attached File  SectorMap.zip   812bytes   0 downloads

 

 

 

Map macro.

 

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

 

Attached File  Map.zip   681bytes   0 downloads

 

 

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

 

 

Attached File  buysell.zip   1.49KB   0 downloads

 

Attached File  CargoCheck.zip   571bytes   0 downloads

 

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.

 

Attached File  Warping.zip   1.35KB   0 downloads

 

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.

 

Attached File  CargoToStation.zip   927bytes   0 downloads

 

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.

Attached File  stationrun.zip   938bytes   0 downloads

 

 


Ego is not a dirty word


#3 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 03 January 2019 - 01:25 AM

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.

 

Attached File  SPS V2.0.zip   1.78KB   0 downloads

 

 

 

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

 

Attached File  SPS V.2.0.zip   1.78KB   2 downloads

Attached File  BuySell.zip   1.32KB   4 downloads

Attached File  CargoCheck.zip   391bytes   1 downloads

Attached File  CargoToStation.zip   737bytes   1 downloads

Attached File  Map.zip   492bytes   2 downloads

Attached File  Objects.zip   630bytes   1 downloads

Attached File  SectorMap.zip   560bytes   1 downloads

Attached File  StationRun.zip   719bytes   1 downloads

Attached File  Warping.zip   897bytes   1 downloads


Ego is not a dirty word


#4 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 03 January 2019 - 01:26 AM

Charon Level 50 Terminal Explore Run PlaceHolder.


Ego is not a dirty word


#5 The WABBIT

The WABBIT

    Forum Master

  • Moderators
  • 641 posts
  • LocationDenver, Colorado

Posted 03 January 2019 - 08:58 AM

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


Do the following before posting, or asking:


1) Read the AC Tool Help File.
2) Read the Release Notes, aka the README.TXT file, for any new information not in the AC Tool Help file.
3) Read through the AC Tool FAQ.
4) Try to code the script/macro you want.
5) Look at any of the script/macros posted on the forums. Use them as examples of what can be done for your game and script/macro.
6) If you are having problems, or don't know how to do something. Then search the AC Tool Support Forums.
7) If you still need help. Then post a new topic with complete detailed information, about what you are trying to do. And what is happening in the script/macro. Plz include your script/macro as outlined in the FAQ.



If you do not read the Help file or the readme.txt file. Then you will not learn how to create a script/macro.

If you do not search the forums. Then you will never now about the answer to your question/problem, that more than likely already exists.

If you do not post complete detailed information, with script/macro, as per the AC Tool FAQ. Then you are just wasting everyone's time.


#6 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 03 January 2019 - 02:37 PM

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.


Ego is not a dirty word


#7 The WABBIT

The WABBIT

    Forum Master

  • Moderators
  • 641 posts
  • LocationDenver, Colorado

Posted 04 January 2019 - 01:00 AM

--- 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.


Do the following before posting, or asking:


1) Read the AC Tool Help File.
2) Read the Release Notes, aka the README.TXT file, for any new information not in the AC Tool Help file.
3) Read through the AC Tool FAQ.
4) Try to code the script/macro you want.
5) Look at any of the script/macros posted on the forums. Use them as examples of what can be done for your game and script/macro.
6) If you are having problems, or don't know how to do something. Then search the AC Tool Support Forums.
7) If you still need help. Then post a new topic with complete detailed information, about what you are trying to do. And what is happening in the script/macro. Plz include your script/macro as outlined in the FAQ.



If you do not read the Help file or the readme.txt file. Then you will not learn how to create a script/macro.

If you do not search the forums. Then you will never now about the answer to your question/problem, that more than likely already exists.

If you do not post complete detailed information, with script/macro, as per the AC Tool FAQ. Then you are just wasting everyone's time.


#8 Suulka

Suulka

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 09 March 2019 - 04:16 AM

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.



#9 Ego

Ego

    Insane Poster

  • Moderators
  • 422 posts
  • LocationAustralia

Posted 09 March 2019 - 03:33 PM

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.

 

Attached File  SPS 3.1.zip   7.52KB   2 downloads

 

 

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.


Ego is not a dirty word