Logfehler beim Konfigurieren

  • Hallo Freunde des Lua-Scriptings (oder auch nicht)


    Ich habe ein Problem mit einem meiner Scripts, nämlich haut es mir immer, wenn ich den Traktor konfigurieren will, einen Fehler in die log. Der Fehler wird geschrieben, wenn man im Konfigurations-Menü auf "Konfigurieren" klickt (also wenn man fertig ist).
    Im Script geht es darum, die Sounds je nach Motorkonfiguration zu wechseln (ist standardmäßig leider nicht möglich).
    Ingame funktioniert alles auch einwandfrei, abgesehen von den Logfehlern.


    Hier das Script, wie es aktuell aussieht:
    [expander][lua]-- motorsoundConfiguration.lua
    -- sets an individual engine sound for engine configurations
    --
    -- Author Rival
    -- 26.10.2016


    motorsoundConfiguration = {};


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


    function motorsoundConfiguration:load(savegame)
    if self.isClient then
    self.sampleMotorStart312 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorConfigurations.motorConfiguration(1).motorStartSound", nil, self.baseDirectory);
    self.sampleMotorStop312 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorConfigurations.motorConfiguration(1).motorStopSound", nil, self.baseDirectory);
    self.sampleMotor312 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorConfigurations.motorConfiguration(1).motorSound", nil, self.baseDirectory, self.components[1].node);
    self.sampleMotorRun312 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorConfigurations.motorConfiguration(1).motorSoundRun", nil, self.baseDirectory, self.components[1].node);
    self.sampleMotorLoad312 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorConfigurations.motorConfiguration(1).motorSoundLoad", nil, self.baseDirectory, self.components[1].node);

    self.sampleMotorStart310 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorStartSound", nil, self.baseDirectory);
    self.sampleMotorStop310 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorStopSound", nil, self.baseDirectory);
    self.sampleMotor310 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorSound", nil, self.baseDirectory, self.components[1].node);
    self.sampleMotorRun310 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorSoundRun", nil, self.baseDirectory, self.components[1].node);
    self.sampleMotorLoad310 = SoundUtil.loadSample(self.xmlFile, {}, "vehicle.motorSoundLoad", nil, self.baseDirectory, self.components[1].node);
    end;
    self.sound310 = true;
    end;
    function motorsoundConfiguration:delete()
    if self.isClient then
    if self.sampleMotor310.sample ~= nil then SoundUtil.deleteSample(self.sampleMotor310); end;
    if self.sampleMotorRun310.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorRun310); end;
    if self.sampleMotorLoad310.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorLoad310); end;
    if self.sampleMotorStart310.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorStart310); end;
    if self.sampleMotorStop310.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorStop310); end;

    if self.sampleMotor312.sample ~= nil then SoundUtil.deleteSample(self.sampleMotor312); end;
    if self.sampleMotorRun312.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorRun312); end;
    if self.sampleMotorLoad312.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorLoad312); end;
    if self.sampleMotorStart312.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorStart312); end;
    if self.sampleMotorStop312.sample ~= nil then SoundUtil.deleteSample(self.sampleMotorStop312); end;
    end;
    end;
    function motorsoundConfiguration:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function motorsoundConfiguration:keyEvent(unicode, sym, modifier, isDown)
    end;
    function motorsoundConfiguration:update(dt)
    end;
    function motorsoundConfiguration:updateTick(dt)
    if self:getIsActive() and self.isClient then
    if self.configurations["motor"] == 2 and self.sound310 then
    if self.sampleMotorStart312 ~= nil and self.sampleMotor312 ~= nil and self.sampleMotorLoad312 ~= nil then
    self.sampleMotorStart.sample = self.sampleMotorStart312.sample;
    self.sampleMotorStop.sample = self.sampleMotorStop312.sample;
    self.sampleMotor.sample = self.sampleMotor312.sample;
    self.sampleMotorRun.sample = self.sampleMotorRun312.sample;
    self.sampleMotorLoad.sample = self.sampleMotorLoad312.sample;
    self.sampleMotorStart.sound3D = self.sampleMotorStart312.sound3D;
    self.sampleMotorStop.sound3D = self.sampleMotorStop312.sound3D;
    self.sampleMotor.sound3D = self.sampleMotor312.sound3D;
    self.sampleMotorRun.sound3D = self.sampleMotorRun312.sound3D;
    self.sampleMotorLoad.sound3D = self.sampleMotorLoad312.sound3D;
    self.sound310 = false;
    end;
    elseif self.configurations["motor"] == 1 and not self.sound310 then
    if self.sampleMotorStart310 ~= nil and self.sampleMotor310 ~= nil and self.sampleMotorLoad310 ~= nil then
    self.sampleMotorStart.sample = self.sampleMotorStart310.sample;
    self.sampleMotorStop.sample = self.sampleMotorStop310.sample;
    self.sampleMotor.sample = self.sampleMotor310.sample;
    self.sampleMotorRun.sample = self.sampleMotorRun310.sample;
    self.sampleMotorLoad.sample = self.sampleMotorLoad310.sample;
    self.sampleMotorStart.sound3D = self.sampleMotorStart310.sound3D;
    self.sampleMotorStop.sound3D = self.sampleMotorStop310.sound3D;
    self.sampleMotor.sound3D = self.sampleMotor310.sound3D;
    self.sampleMotorRun.sound3D = self.sampleMotorRun310.sound3D;
    self.sampleMotorLoad.sound3D = self.sampleMotorLoad310.sound3D;
    self.sound310 = true;
    end;
    end;
    end;
    end;
    function motorsoundConfiguration:draw()
    end;[/lua][/expander]
    Und der Logfehler lautet folgendermaßen:
    [expander]

    [/expander]


    Ich vermute, dass es mit dem deleteSample in der motorized.lua zusammenhängt. Alle Versuche, den Fehler zu verhindern, waren aber erfolglos.


    Weiß da vielleicht irgendjemand eine Lösung?



    MfG

  • Frage: Warum baust du ein komplett neues Script, verwendest "Configuration" im Namen, aber keine Configs im Script selbst?


    Du machst es dir damit nur unnötig kompliziert.
    Einfachste und gleichzeitig sauberste Lösung:
    1. Gesamte "loadSounds" Funktion kopieren
    2. Analog zur "loadMotor" Funktion das auslesen der XML Werte korrigieren
    3. Originale "loadSounds" Funktion überschreiben


    Ist in wenigen Minuten erledigt (deutlich schneller als ein eigenes Script schreiben), würde sogar ein Laie hinbekommen (also zumindest sofern man solche logischen Zusammenhänge erkennen kann) und ist die einzig mir bekannte saubere Lösung für das Problem.

Jetzt mitmachen!

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