Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2012, 4:42:19 PM (13 years ago)
Author:
landauf
Message:

quick fix: use tcl instead of shell commands to find ship templates for ship selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/data/gui/scripts/ShipSelectionMenu.lua

    r9281 r9282  
    66P.shipList = {}
    77function P.onLoad()
    8    local dircmd = "ls -l ../levels/templates/ | awk '{print $9}' | grep \"spaceship\" | sed -e 's/\\.[a-zA-Z]*$//'" -- go to spaceships folder and generate a list of installed shipmodels.
    9    os.execute(dircmd .. " > ../levels/templates/.shipmodels") --saves output in a textfile
    10    --[[TODO: program a Windows Version / platform independent version here:
    11    if string.sub(package.config,1,1) == '\\' then
    12            -- Windows
    13            dircmd = "dir /b/s"
    14    end]]
    15    P.createFilterTab("All Ships")
     8    orxonox.execute("set shipmodelsfile [open {../levels/templates/.shipmodels} w+]")
     9    orxonox.execute("foreach line [glob -directory ../levels/templates/ spaceship*] { regexp {.*/(.*)\\..*} $line matchall match1; puts $shipmodelsfile $match1 }")
     10    orxonox.execute("close $shipmodelsfile")
     11    P.createFilterTab("All Ships")
    1612end
    1713
    1814function P.createShipList() --generates list with tagged shipmodels
    19    P.shipList = {}
    20    for line in io.lines("../levels/templates/.shipmodels") do  --checks if shipmodel is included in level file
    21     if selectedlevel:hasStartingShip(string.lower(line)) then
    22         P.shipList[#P.shipList+1] = string.lower(line)
     15    P.shipList = {}
     16    file = io.open("../levels/templates/.shipmodels")
     17    if file ~= nil then
     18        for line in file:lines() do  --checks if shipmodel is included in level file
     19            if selectedlevel:hasStartingShip(string.lower(line)) then
     20                P.shipList[#P.shipList+1] = string.lower(line)
     21            end
     22        end
     23        --file.close() -- TODO: investigate why close() seems to crash?
    2324    end
    24    end
    2525end
    2626
Note: See TracChangeset for help on using the changeset viewer.