Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Command: array push/pop/count/removeAt #67

Open
joemcbride opened this issue Apr 6, 2017 · 1 comment
Open

Script Command: array push/pop/count/removeAt #67

joemcbride opened this issue Apr 6, 2017 · 1 comment
Labels
enhancement New feature or request

Comments

@joemcbride
Copy link
Member

joemcbride commented Apr 6, 2017

Idea for a new script command: array

# add value to an array
array push myArray one

# %myArray = one

array push myArray two

# %myArray = one|two

# remove last value
array pop myArray

# %myArray = one

# get number of elements in array
eval count array count myArray

# %count = 1

# index into array
# %myArray[0] = one
# %myArray(0) = one

# remove a value at an index
var myArray one|two|three
array removeAt 1 myArray

# %myArray = one|three

var myArray one|two|three
eval item array first myArray
eval item array lowest myArray

# %item = one

var myArray one|two|three
eval item array last myArray
eval item array highest myArray

# %item = three

array slice??
array splice??

# When sort compares two values, it sends the values to the compare function,
# and sorts the values according to the returned (negative, zero, positive) value.

var myArray Enchanting|Alchemy|Engineering

array sort myArray sortAsc
array sort myArray sortDesc

sortAsc:
  var targetArray $1
  var itemA $2
  var itemB $3
  var indexA $4
  var indexB $5

  # expects -1 < 0 < 1 to sort
  return %itemA.LearningRate - %itemB.LearningRate

sortDesc:
  var targetArray $1
  var itemA $2
  var itemB $3
  var indexA $4
  var indexB $5

  # expects -1 < 0 < 1 to sort
  return %itemB.LearningRate - %itemA.LearningRate
@joemcbride joemcbride added the enhancement New feature or request label Apr 6, 2017
@HanryuDR
Copy link
Contributor

HanryuDR commented Apr 7, 2017 via email

@joemcbride joemcbride transferred this issue from outlander-app/outlander-osx Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants