Hey all, I was hoping I could ask some dumb questions. I have no real coding experience so I'm trying to figure things out but kinda stuck..
I'm trying to make an auto-navigation script for Fed2 that takes "go <dest>", checks where I currently am, and gets directions from a static data table to get from <current> to <dest>, if that makes sense.. I've got some of the syntax figured out, but I'm not quite sure how to set up such a table/database in the first place. Everything I've read about tables seems to address storing a couple of variables for one entry. However, this table would store 7 data points for a large number of entries. I'm happy to share the (probably not so good) start to my code if that helps.
Help with Tables/Scripting
Re: Help with Tables/Scripting
Each item could be its own table. I've collected tables with thousands and thousands of entries, no problem.
Re: Help with Tables/Scripting
Thanks. So once the table is created, how can I call the data within it? I.e., the script would trigger on something like ^go <destPlanet>$. If I have two variables, currentPlanet, which is updated by this script and other aliases, and destPlanet = matches[2] from the 'go' command, would my syntax be
or would the tables.matches(currentPlanet... look for a table called currentPlanet and return an error?
I'm including what I've got so far with my comments just to make what I'm trying to figure out a little clearer.
Here is an example table that I've got from your previous post:
So in the example above, if I were on Sakura and wanted to travel to Goldenshoe, the currentPlanet variable would = Sakura and destPlanet = Goldenshoe, and the script would look up directions from Sakura to its main hub link, and then from that link to Goldenshoe.
Code: Select all
speedwalk(tables.matches(currentPlanet, fromExchange))
I'm including what I've got so far with my comments just to make what I'm trying to figure out a little clearer.
Code: Select all
-- Table has the following information stored:
-- PlanetName - name of Planet
-- System - star system of Planet
-- Cartel -- star systems are collected into several "cartel" star systems
-- in a hub-and-spoke system
-- Cartels serve as hubs to other cartels and can travel directly to
-- Systems contained within them and also other Cartels
-- Systems can travel directly to other Systems within their parent
-- cartel, otherwise they must travel to the Cartel hub
-- fromLink -- Each system has its own outer space and a designated hyperlink
-- to travel to/from other systems/cartels
-- fromLink provides navigation from the System/Cartel hyperlink
-- through the System's space to PlanetName
-- toLink -- contains directions from PlanetName back to Link
-- if PlanetName shares a location with the Link, then fromLink and
-- toLink will be empty [] and there is nothing to send below
-- toExchange -- directions from Planet to its trading exchange
-- fromExchange -- directions back to Landing Pad
destPlanet = matches[2]
-- there should be a variable currentPlanet that can be used by this and
-- other aliases so that the script knows where you are
-- Find out what planet we are standing on if this is the first time starting
-- match currentPlanet and destPlanet to PlanetName in the table, error if either is not found
speedwalk(currentPlanet.fromExchange) -- must be in the exchange to start the command or else you might get lostt
send("buy fuel") -- to make sure you don't get stuck in space
tempTimer(1, [[ send("board" ]])
speedwalk(currentPlanet.toLink)
-- Check to see what cartel destPlanet is in and either jump directly to spoke or navigate to the hub link
if currentPlanet.Cartel == destPlanet.Cartel
then send("j " destPlanet.System) -- and then go to next step
else send("j " currentPlanet.Cartel) -- travel to hubs and then destination spoke
send("j " destPlanet.Cartel)
send("j " destPlanet.System)
speedwalk(destPlanet.fromLink)
tempTimer(1, [[ send("board" ]])
speedwalk(destPlanet.toExchange)
-- You have arrived at your destination and we can update currentPlanet to
-- where you are now
currentPlanet = destPlanet
Code: Select all
Sakura = {
planetName="Sakura",
system="Enso",
cartel="Flight",
fromLink = " ",
toLink = " ",
fromExchange="s",
toExchange="n"
},
Goldenshoe = {
planetName="Goldenshoe",
system="Meadows",
cartel="Meadows",
fromLink="w, n",
toLink="s, e",
fromExchange="e",
toExchange="w"
},