Skript Fehler

User avatar
MrTomkaot
Posts: 563
Joined: Sat Oct 04, 2014 7:37 pm

Skript Fehler

Post by MrTomkaot » Sun Jan 17, 2016 10:32 pm

Guten Tag

Ich versuche mir ein SkriptMod aus LS 13 zu LS 15 zu konvertieren.
Soweit funktioniert alles bis auf eine Fehlermeldung:
Error: Running LUA method 'update'.
C:/Users/Tom/Documents/My Games/FarmingSimulator2015/mods//zzz_parkButtonGlobal/parkButton.lua:61: attempt to perform arithmetic on field 'ingameMapWidth' (a nil value)
Skript:
parkButton = {};

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

function parkButton:load(xmlFile)
self.setparkButtonMode = SpecializationUtil.callSpecializationsFunction("setparkButtonMode");
self.parkMode = false;
self.parkHotspot = nil;
end;

function parkButton:delete()
if self.parkHotSpot ~= nil then
g_currentMission.missionPDA:deleteMapHotspot(self.parkHotSpot);
end;
end;

function parkButton:readStream(streamId, connection)
self:setparkButtonMode(streamReadBool(streamId), true);
end;

function parkButton:writeStream(streamId, connection)
streamWriteBool(streamId, self.parkMode);
end;

function parkButton:mouseEvent(posX, posY, isDown, isUp, button)
end;

function parkButton:keyEvent(unicode, sym, modifier, isDown)
end;

function parkButton:update(dt)
if self:getIsActive() and self:getIsActiveForInput(false) and self.isClient then
if InputBinding.hasEvent(InputBinding.parkCar) then
self:setparkButtonMode(not self.parkMode);
end;
end;
end;

function parkButton:updateTick(dt)
end;

function parkButton:draw()
if g_currentMission.showHelpText and self.isClient then
if self.parkMode then
g_currentMission:addHelpButtonText(g_i18n:getText("unparkCar"), InputBinding.parkCar);
else
g_currentMission:addHelpButtonText(g_i18n:getText("parkCar"), InputBinding.parkCar);
end;
end;
end;

function parkButton:setparkButtonMode(parkMode, noEventSend)
if parkMode ~= nil then
self.parkMode = parkMode;
self.nonTabbable = parkMode;
parkButtonEvent.sendEvent(self, parkMode, noEventSend);
if self.parkMode then
local x, y, z = getWorldTranslation(self.rootNode);
local iconSize = g_currentMission.ingameMap.Width / 15;
if g_currentMission.parkSpotIcon ~= nil then
self.parkHotSpot = g_currentMission.ingameMap:createMapHotspot("Parkedcar", g_currentMission.parkSpotIcon, x, z, iconSize, iconSize * (4 / 3), false, false, false, 0, true);
end;
else
if self.parkHotSpot ~= nil then
g_currentMission.ingameMap:deleteMapHotspot(self.parkHotSpot);
self.parkHotSpot = nil;
end;
end;
end;
end;

function parkButton:getSaveAttributesAndNodes(nodeIdent)
local attributes = "";
attributes = 'parkMode="'..tostring(self.parkMode)..'"';
return attributes, nil;
end;
function parkButton:loadFromAttributesAndNodes(xmlFile, key, resetVehicles)
local parkMode = Utils.getNoNil(getXMLBool(xmlFile, key .. "#parkMode"), false);
self:setparkButtonMode(parkMode);
return BaseMission.VEHICLE_LOAD_OK;
end;

------------------------------------------------------------

parkButtonEvent = {};
parkButtonEvent_mt = Class(parkButtonEvent, Event);

InitEventClass(parkButtonEvent, "parkButtonEvent");

function parkButtonEvent:emptyNew()
local self = Event:new(parkButtonEvent_mt);
self.className="parkButtonEvent";
return self;
end;

function parkButtonEvent:new(vehicle, parkMode)
local self = parkButtonEvent:emptyNew()
self.vehicle = vehicle;
self.parkMode = parkMode;
return self;
end;

function parkButtonEvent:readStream(streamId, connection)
local id = streamReadInt32(streamId);
self.parkMode = streamReadBool(streamId);
self.vehicle = networkGetObject(id);
self:run(connection);
end;

function parkButtonEvent:writeStream(streamId, connection)
streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
streamWriteBool(streamId, self.parkMode);
end;

function parkButtonEvent:run(connection)
self.vehicle:setparkButtonMode(self.parkMode, true);
if not connection:getIsServer() then
g_server:broadcastEvent(parkButtonEvent:new(self.vehicle, self.parkMode), nil, connection, self.object);
end;
end;
function parkButtonEvent.sendEvent(vehicle, parkMode, noEventSend)
if noEventSend == nil or noEventSend == false then
if g_server ~= nil then
g_server:broadcastEvent(parkButtonEvent:new(vehicle, parkMode), nil, nil, vehicle);
else
g_client:getServerConnection():sendEvent(parkButtonEvent:new(vehicle, parkMode));
end;
end;
end;
Ich habe schon einen Eintrag getauscht, ohne Erfolg. Weis jemand wie ich diesen Fehler beheben kann? Danke im Vorraus
Wenn die Glaskugel kommt dann heißt es,log.txt posten!
http://wiki.giants-software.com/index.p ... tig_posten

Tutorial "2 Joysticks mit Lenkrad in LS15 nutzen"
http://forum.giants-software.com/viewto ... 27&t=72854

mngrazy
Posts: 669
Joined: Fri May 10, 2013 3:22 pm

Re: Skript Fehler

Post by mngrazy » Sun Jan 17, 2016 10:39 pm

local iconSize = g_currentMission.ingameMap.mapWidth / 15;

:hi:

User avatar
MrTomkaot
Posts: 563
Joined: Sat Oct 04, 2014 7:37 pm

Re: Skript Fehler

Post by MrTomkaot » Sun Jan 17, 2016 11:01 pm

Vielen Dank
Hat funktioniert *thumbsup*
Wenn die Glaskugel kommt dann heißt es,log.txt posten!
http://wiki.giants-software.com/index.p ... tig_posten

Tutorial "2 Joysticks mit Lenkrad in LS15 nutzen"
http://forum.giants-software.com/viewto ... 27&t=72854

Post Reply