[lua] function GetEstimatedTime and function postTaxiNodeOnButtonEnter
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- local function GetEstimatedTime(slot) -- estimates flight times based on hops
- local etime, numnodes = 0, NumTaxiNodes()
- for hop = 1, GetNumRoutes(slot), 1 do
- local s, sx, sy = nil, floor(100 * TaxiGetSrcX(slot, hop)), floor(100 * TaxiGetSrcY(slot, hop))
- local d, dx, dy = nil, floor(100 * TaxiGetDestX(slot, hop)), floor(100 * TaxiGetDestY(slot, hop))
- for i = 1, numnodes, 1 do
- local ix, iy = TaxiNodePosition(i)
- ix, iy = floor(100 * ix), floor(100 * iy)
- if not s and sx == ix and sy == iy then
- s = ShortenName(FixTypos(TaxiNodeName(i))) --ShortenName(TaxiNodeName(i))
- end
- if not d and dx == ix and dy == iy then
- d = ShortenName(FixTypos(TaxiNodeName(i))) --ShortenName(TaxiNodeName(i))
- end
- if s and d then break end
- end
- if s and d and vars[s] and vars[s][d] then
- etime = etime + vars[s][d]
- else
- return nil
- end
- end
- return etime
- end
- local function postTaxiNodeOnButtonEnter(button) -- adds duration info to node tooltips
- local id = button:GetID()
- GameTooltipTextLeft1:SetText(FixTypos(TaxiNodeName(id)))
- if TaxiNodeGetType(id) ~= "REACHABLE" then
- return
- end
- local ftime = (vars[source] and vars[source][ ShortenName(FixTypos(TaxiNodeName(id))) ]) --ShortenName(TaxiNodeName(id))
- or GetEstimatedTime(id) or 0
- if ftime > 0 then
- gtt:AddLine(L_duration..FormatTime(ftime), 1, 1, 1)
- else
- gtt:AddLine(L_duration.."-:--", 0.8, 0.8, 0.8)
- end
- gtt:Show()
- end
Editor
You can edit this paste and save as new: