December 22, 2024, 06:07:39

Author Topic: Arrays?  (Read 7309 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Arrays?
« on: August 15, 2009, 14:27:57 »
Anyone found a clever way to store values in array-like structures?

Basically I've got at least three MACHINEs. One of them calls an event, that the other two implemented. I'm also delivering a certain playerID event variable with that event call. Based on that playerID variable only one of the other two MACHINEs is supposed to respond. That means both MACHINEs need to know the playerID they're supposed to respond to. However, they should be able to respond to more than one playerID. In a real programming language I'd simply store the playerIDs in an array and check, if the supplied playerID is in that array, but Nexus scripting doesn't know arrays. I've tried it with selections and AddItem(), but they expect objects, not values - especially not numbers.

Any idea for an elegant solution?

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #1 on: August 15, 2009, 16:12:48 »
How viable would it be to have a rule that'd create a navpoint and assign it a player id?  As far as I'm aware, there's no limit on the number of NP's that you can have and they only show up in the game if requested.  

Might not be elegant, but it would give you an object to go with the name.
Better to look the fool by asking, then prove them right with ignorance.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #2 on: August 15, 2009, 20:27:31 »
Hmm... nice idea, but how would I create a navpoint during the mission? I can only create objects using CreateShip() and that expects a shiptype and not a shipclass and I don't want to touch the tacticstypes.ini :(

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #3 on: August 15, 2009, 21:50:58 »
create navig points? that's the easiest! just use the AddNavigPoint( command :)
for example:

Nav1:= AddNavigPoint("waipoint 1", -16824, 16045, 30126, 1,1,1, #race_player);
as far as I'm concerned they can be created in-mission.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #4 on: June 05, 2010, 18:25:13 »
I long this is long overdue, but even though there aren't any arrays in nexus, you can use lists instead:

Dim(list number);

Empty(list);
ClearSelect(list); //they "free", delete, the given list

setN(list, place, element); //it adds an element on that place (I think it only handles numbers... but I never gave it a thorough test)

getN(list, place);
pickN(list,place); //they returns the element located on "place"

and many more ADT functions. Although not arrays, they're close enough.