[gelöst] Error bei selbst einbauendem script (HUD)

  • Hi Leute


    ich versuche gerade scripten zu lernen und irgendwie komme ich auf keinen grünen Zweig


    und so siehts im moment aus:
    ich versuche ein selbst installierendes script für alle motorized fahrzeuge zu basteln. ich habe mir zuerst mal das script zum automatischen einbau von hier genommen variablen geändert also so:
    [lua]SpecializationUtil.registerSpecialization("HighControl", "HighControl", g_currentModDirectory.."HighControl.lua")



    print("--- HighControl - specialization for manual motor ignition ---");


    for k,v in pairs(VehicleTypeUtil.vehicleTypes) do
    if v~=nil then
    for a=1, table.maxn(v.specializations) do
    local s = v.specializations[a];
    if s ~= nil then
    if s == SpecializationUtil.getSpecialization("motorized") then
    print("adding HighControl to:"..tostring(v.name));
    table.insert(v.specializations, SpecializationUtil.getSpecialization("HighControl"));
    end;
    end;
    end;
    end;
    end;[/lua]
    soweit so gut und bis dahin keine Probleme


    nun habe ich mir eine sample lua heruntergeladen und dort versucht ein wenigzu scripten. Ganz einfach anfangen (glaubte ich) und mal ein hud anzeigen lassen. Habe mir die es_limiter lua angeschaut und zwei zeilen heraus kopiert um das hud anzeigen zu lassen, angepasst und das Spiel gestartet. Während man den Spielstand lädt kommt ein error in der log und das Spiel hört nicht auf zu laden


    der lua text:
    [lua]HighControl = {};


    function HighControl.prerequisitesPresent(specializations)
    return true
    end;


    local hc_directory = g_currentModDirectory;


    function HighControl:load(xmlFile)
    self.HighControl.hudTerminal = Overlay:new("hudTerminal", Utils.getFilename("hudterminal.png", hc_directory), 0.5, 0.5, 0.5, 0.5);
    end;
    function HighControl:delete()
    end;
    function HighControl:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function HighControl:keyEvent(unicode, sym, modifier, isDown)
    end;
    function HighControl:update(dt)
    end;
    function HighControl:updateTick(dt)
    end;
    function HighControl:draw()
    self.HighControl.hudTerminal:render();
    end;[/lua]


    in der log dieser error:


    Error: LUA running function 'loadSharedI3DFileFinished'
    D:/code/lsim2013/build/finalbin/dataS/scripts/vehicles/Vehicle.lua(902) : bad argument #1 to '?' (function expected, got table)


    ich habe schon mehrere sachen versuch leider keinen Erfolg.


    Würde mich freuen wenn jemand helfen könnte


    mfg Fendt Xerion 3800

  • [lua]SpecializationUtil.registerSpecialization("HighControl", "HighControl", g_currentModDirectory.."HighControl.lua")



    print("--- HighControl - specialization for manual motor ignition ---");


    function HighControl _Register:loadMap(name)
    for k, v in pairs(VehicleTypeUtil.vehicleTypes) do
    if SpecializationUtil.hasSpecialization(Motorized, v.specializations) then
    table.insert(v.specializations, SpecializationUtil.getSpecialization("HighControl"));
    end;
    end;


    end;


    function HighControl _Register:deleteMap()
    end;
    function HighControl _Register:keyEvent(unicode, sym, modifier, isDown)
    end;
    function HighControl _Register:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function HighControl _Register:update(dt)
    end;
    function HighControl _Register:draw()
    end;
    [/lua]


    Und die HighControl Lua.


    [lua]HighControl = {};
    hc_directory = g_currentModDirectory;


    function HighControl.prerequisitesPresent(specializations)
    return true
    end;




    function HighControl:load(xmlFile)
    self.HighControlhudTerminal = Overlay:new("hudTerminal", (hc_directory, "hudterminal.png" ), 0.5, 0.5, 0.5, 0.5);
    end;
    function HighControl:delete()
    end;
    function HighControl:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function HighControl:keyEvent(unicode, sym, modifier, isDown)
    end;
    function HighControl:update(dt)
    end;
    function HighControl:updateTick(dt)
    end;
    function HighControl:draw()
    self.HighControlhudTerminal:render();
    end;[/lua]




    Der Fehler mit dem got table, könnte schon davon kommen, das du geschrieben hast: self.HighControl.hudTerminal, sprich du greifst dort wieder auf einen table zu, nämlich .hudTerminal!

  • Ich habe das ganze jetzt nochmal getestet.


    Mein Fehler war in den beispielen schon die Leerzeichen die ich übernommen hatte von dir.


    Habe es jetzt so das du die Register in der Moddesc einträgst, die HighControl.Lua normal in der Zip lässt und dein HUD auch in die zip packst, ohne irgendwelche Unterordner usw.


    [lua]SpecializationUtil.registerSpecialization("HighControl", "HighControl", g_currentModDirectory.."HighControl.lua")


    HighControlRegister = {};
    print("--- HighControl - specialization for manual motor ignition ---");


    function HighControlRegister:loadMap(name)
    for k, v in pairs(VehicleTypeUtil.vehicleTypes) do
    if SpecializationUtil.hasSpecialization(Motorized, v.specializations) then
    table.insert(v.specializations, SpecializationUtil.getSpecialization("HighControl"));
    end;
    end;


    end;


    function HighControlRegister:deleteMap()
    end;
    function HighControlRegister:keyEvent(unicode, sym, modifier, isDown)
    end;
    function HighControlRegister:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function HighControlRegister:update(dt)
    end;
    function HighControlRegister:draw()
    end;


    addModEventListener(HighControlRegister);[/lua]



    HighControl.LUA


    [lua]
    HighControl = {};
    hc_directory = g_currentModDirectory;


    function HighControl.prerequisitesPresent(specializations)
    return true;
    end;


    function HighControl:load(xmlFile)
    self.HighControlhudTerminal = createImageOverlay(hc_directory.."hudterminal.dds");
    end;
    function HighControl:delete()
    end;
    function HighControl:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function HighControl:keyEvent(unicode, sym, modifier, isDown)
    end;
    function HighControl:update(dt)
    end;
    function HighControl:updateTick(dt)
    end;
    function HighControl:draw()
    renderOverlay(self.HighControlhudTerminal, 0.5, 0.5, 0.5, 0.5);
    end;
    [/lua]

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!