Using a Table to Chart Course

Posted by Neoshain on Wed 19 Apr 2017 01:20 PM — 3 posts, 15,936 views.

#0
Okay, so I have a plan, just wanna run it by you guys to see if I'm on the right track.

My SWR Mud implemented a new Hyperspace Route system where you have to chart a route from system to system to get across the galaxy.

Let's say I want to go from the Corellian System to the Kashyyyk system, when I'm in the Corellian System I then type
Quote:
chart Kashyyyk


Then, after one minute, I receive

Quote:

[Ship Computer] Hyperspace course charted.
Coruscant System
Chandrila System
Lantillies System
Kashyyyk System


So, I want to take that list, and put it into a Lua Table.

Then I initiate a trigger, just one, but it iterates through the table, as I go through the systems.


Something like this, (I haven't looked up the syntax for Lua tables, yet, so I know this probably isn't correct, I'm thinking of them like arrays for C++, which may be my error) where
i
is set at the initiation of the entire process.


--trigger matches coming out of hyperspace into the current system

Send("calc " .. routeListTable[i] .. " 1000 1000 1000"")

i = i + 1

Amended on Wed 19 Apr 2017 01:24 PM by Neoshain
USA Global Moderator #1
In my experience there's no such thing as a right track. Infinite code paths lead to the same result.
Australia Forum Administrator #2
Your question isn't really answerable. Certainly you can subscript tables in Lua similarly to C (note that subscripts usually start at one, not zero).

As for the rest, try some code and see what happens.