Skip to content

Commit e871a8e

Browse files
committed
added textinput option "a ::pos{system,planet,lat,lon,alt} Displayname"
1 parent a0c44cb commit e871a8e

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Welcome to Trog's SatNav for Dual Universe. This is a location/bookmark manager
111111
f) `l Hud` - this will copy all of the Dimencia Hud stored locations from the Hud's databank into the SatNav databank
112112

113113
g) `x SatNav` - this command will duplicate/clone the SatNav databank if an additional empty databank has been linked to the PB in slot 5. The purpose of this feature is to enable users to copy their locations to multiple ships.
114+
115+
h) `a ::pos{system,planet,lat,lon,alt} Displayname` - will add a new Location to SatNav. Input validation is very basic, thus please use with care.
114116

115117
5. When using your [Dimencia Hud](https://github.com/Dimencia/DU-Orbital-Hud), you will find that the location you loaded in 3 (above) has been renamed as `**SatNav Location**` and is now available using the `Alt+1/Alt+2` keys.. This will also have been set as the destination on the Dim Hud buttons screen.
116118
> Unlike previous versions of SatNav, we now only copy across a single location to Dim Hud - this is due to a limitation in the Dim Hud which would cause a CPU overload error if we copied all of the SatNav locations across.

src/system/inputText.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,22 @@ elseif text == "x SatNav" then
5050
else
5151
system.print("Please link an empty databank to the programming board")
5252
end
53+
elseif string.sub(text,1,2) == "a " then
54+
local newLocNamePos = text:find("}")
55+
if newLocNamePos > 0 then
56+
-- @TODO: add more validation
57+
local newLocPos = string.sub(text,3,newLocNamePos)
58+
local newLocName = string.sub(text, newLocNamePos + 2, string.len(text))
59+
newLocation(newLocName, newLocPos)
60+
if displayPlanetList[1] ~= "" then
61+
lastPlanetSelected = displayPlanetList[1]
62+
lastLocationSelected = ""
63+
buildPlanetLocList(lastPlanetSelected)
64+
clearLocDispList()
65+
selected = ""
66+
CurrentLocationPage=1
67+
CurrentPlanetPage=1
68+
DrawPlanetList()
69+
end
70+
end
5371
end

src/unit/start.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,22 @@ function loadHudLocations()
603603
end
604604

605605

606-
function newLocation ()
607-
local location = system.getWaypointFromPlayerPos()
606+
function newLocation (xnewLocName, newLocPos)
607+
local location
608+
if xnewLocName and newLocPos then
609+
location = newLocPos
610+
else
611+
location = system.getWaypointFromPlayerPos()
612+
end
608613
local newLocId = myDatabank.getIntValue("lastNewLoc") + 1
609614
myDatabank.setIntValue("lastNewLoc",newLocId)
610615

611-
local newLocName = defaultNewLocName.." ("..newLocId..")"
616+
local newLocName
617+
if xnewLocName then
618+
newLocName = xnewLocName
619+
else
620+
newLocName = defaultNewLocName.." ("..newLocId..")"
621+
end
612622

613623
local num = ' *([+-]?%d+%.?%d*e?[+-]?%d*)'
614624
local posPattern = '::pos{' .. num .. ',' .. num .. ',' .. num .. ',' ..

0 commit comments

Comments
 (0)