FANDOM


I created a PowerShell script to help me manage my trading inventory. I list items in the arrays at the top. And the script randomly picks a few and puts them together in a string. The basic workflow is I maintain a list of items I'm interested in by editing the arrays at the top of the script, and the script puts a randomized list of items into my clipboard. Then I go to trade chat and paste. You can only type so much into trade chat. This lets you manage an inventory that is bigger than what can be typed. And it rotates items so they receive equal exposure.

Leave a comment with any questions.

Trade Script.ps1

Trade Script.ps1

$WTB = @(
#"Primed Reach",
#"Voltaic Strike"
)

$WTT = @(
#"Madurai Lens",
"Naramon Lens",
"Unairu Lens", 
"Zenurik Lens"
)

# Mods
$WTS = @(
"Agility Drift", 
"Armored Agility", 
"Riven Mod", # Up to five allowed. 
"Whirlwind"
)

# Parts
$WTS += @(
"Chroma Prime Chassis", # 20p 
#"Chroma Prime Neuroptics", # 15p 
"Snipetron Vandal",
"Synoid Gammacor" #, 20-35p
)


function sendMessage 
{
    param(
        [string]   $announcement = "WTS", 
        [string[]] $tradeItems          ,
        [int]      $myCount      = 10
    )

    $myMessage =  ""
    $myMessage += "$announcement "

    Get-Random -Count $myCount $tradeItems | 
    Sort-Object | 
    % { 
        $myMessage += "[$_] " 
    }

    $myMessage
}

function myMacro ([string] $announcement)
{


$String1 = @" 
    Switch (`$$announcement.Count)
    {
        {   0                          } # condition
            {    }                       # action

        {  (`$_ -gt 0) -and (`$_ -le 3)  } #condition
            {  
                # actions
                `$itemCap -= `$$announcement.Count
                `$finalAnswer += sendMessage "$announcement" `$$announcement (`$$announcement.Count)
            }
    
        {   `$_ -gt 3                   } # condition
            {  
                # actions
                `$itemCap -= 3
                `$finalAnswer += sendMessage "$announcement" `$$announcement 3
            }
    }
"@

    $String1

}


#<#
$itemCap = 9
$finalAnswer = "" 


# Am I willing to buy anything? 
Invoke-Expression (myMacro "WTB") 

# Am I willing to swap (WTT) anything? 
Invoke-Expression (myMacro "WTT") 

# Send selling message. 
$finalAnswer += sendMessage "WTS" $WTS $itemCap

# To console
Get-Date | % { "$_" }
$finalAnswer

# Directly to clipboard
$finalAnswer | clip


#>

Example Output

06/21/2019 04:07:04
WTT [Naramon Lens] [Unairu Lens] [Zenurik Lens] WTS [Armored Agility] [Chroma Pr
ime Chassis] [Riven Mod] [Snipetron Vandal] [Synoid Gammacor] [Whirlwind] 

Change Log

  • Divided $WTS into two arrays to separate parts and mods.
  • Changed $itemCap = 9 to avoid messages that are too long for chat.
  • Using
    Get-Date | % { "$_" }
    to time stamp each script run. I believe I'm piping because that eliminates a stray newline.
  • Added a Riven Mod example. After pasting into chat, you will be prompted to select a mod.
  • Demonstrate comments next to items.
Version 000

Trade Script v000.ps1

$WTB = @(
#"Primed Reach",
#"Voltaic Strike"
)


$WTT = @(
#"Kubrow G",
#"Kubrow B"
)


$WTS = @(
"Agility Drift", 
"Blood Rush",
"Cleaving Whirlwind",
"Coaction Drift",
"Coiling Viper",
"Crushing Ruin",
"Endurance Drift", 
"Hydraulic Crosshairs",
"Jagged Edge",
"Power Drift",
"Relentless Combination",
"Scattering Inferno",
"Shrapnel Shot",
"Twirling Spire",
"Whirlwind"
)


function sendMessage 
{
    param(
        [string]   $announcement = "WTS", 
        [string[]] $tradeItems          ,
        [int]      $myCount      = 10
    )

    $myMessage =  ""
    $myMessage += "$announcement "

    Get-Random -Count $myCount $tradeItems | 
    Sort-Object | 
    % { 
        $myMessage += "[$_] " 
    }

    $myMessage
}

function myMacro ([string] $announcement)
{


$String1 = @" 
    Switch (`$$announcement.Count)
    {
        {   0                          } # condition
            {    }                       # action

        {  (`$_ -gt 0) -and (`$_ -le 3)  } #condition
            {  
                # actions
                `$itemCap -= `$$announcement.Count
                `$finalAnswer += sendMessage "$announcement" `$$announcement (`$$announcement.Count)
            }
    
        {   `$_ -gt 3                   } # condition
            {  
                # actions
                `$itemCap -= 3
                `$finalAnswer += sendMessage "$announcement" `$$announcement 3
            }
    }
"@

    $String1

}


$itemCap = 10
$finalAnswer = "" 


# Am I willing to buy anything? 
Invoke-Expression (myMacro "WTB") 

# Am I willing to swap (WTT) anything? 
Invoke-Expression (myMacro "WTT") 

# Send selling message. 
$finalAnswer += sendMessage "WTS" $WTS $itemCap


# To console
$finalAnswer

# Directly to clipboard
$finalAnswer | clip

Example Output

WTS [Agility Drift] [Blood Rush] [Cleaving Whirlwind] [Coaction Drift] [Coiling 
Viper] [Crushing Ruin] [Relentless Combination] [Scattering Inferno] [Shrapnel S
hot] [Twirling Spire] 

Change Log

  • Original version.
Community content is available under CC-BY-SA unless otherwise noted.