Fancy Array script. Drop-in, use.

Talk about Tribes (anything but RPG) here.
Post Reply
Posts: 3
Joined: Sat Oct 16, 2021 3:10 pm

Fancy Array script. Drop-in, use.

Post by DescX »

See these links for drop-in Array implemented as script-only. Supports size checking, range insertion, range erasure, shrinking, copying, deletion, automatic names for throwaway arrays, custom null markers, and positional fills.

Have I just re-invented the wheel? Almost certainly, yes! I coudn't find any examples of code that let me manage arrays without going mad, and I wasn't about to try writing a DLL. The script is definitely not perfect, it's a couple-hour-job, but it includes an automated test to prove it works. Run it to make sure I didn't screw up :). If I discover any serious problems I'll update.

Here's the function list:
  • Array::New -> Register a new array. Specify what NULL should be, and/or a custom name. Return the name.
  • Array::Delete -> Delete a registered array.
  • Array::Get -> Index accessor
  • Array::Insert -> Range-enabled insert
  • Array::Fill -> Insert a delimited list of values starting at a given position
  • Array::EraseRange -> Null a range of elements. Do nothing else.
  • Array::Shrink -> Remove all NULL values and compact the array
  • Array::RemoveRange -> EraseRange, and then Shrink
  • Array::Valid -> Check if the array was registered with New()
  • Array::Copy -> Copy a registered array into destination registered array. Frees the destination first.
  • Array::CopyToWorld -> Quick hack for saving arrays in TRPG.
  • Array::CopyFromWorld-> Same as CopyToWorld, but in reverse.

Post Reply