Community Forum

Trigger for buildings - error

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created18.01.2011 20:33


Przemysław Lipiński (unknown) 18.01.2011 20:53
I want made script for building works in multiplayer. I used example script for tip trigger but i have error in game. This is my error in log.txt:

<--log.txt-->
Call Stack:
D:/code/lsim2011/build/finalbin/dataS/scripts/network/ObjectIds.lua(55) : printCallstack
D:/code/lsim2011/build/finalbin/dataS/scripts/network/ObjectIds.lua(30) : assignObjectClassObjectId
C:/Users/Lipa/Documents/My Games/FarmingSimulator2011/mods/ruchomedrzwi/Ruchoma_brama.lua(7) : InitStaticObjectClass
=[C](-1)
D:/code/lsim2011/build/finalbin/dataS/scripts/main.lua(1170) : source
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/MPLoadingScreen.lua(251) : loadMod
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/MPLoadingScreen.lua(131) : initializeLoading
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/CareerScreen.lua(281) : startLocal
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/CareerScreen.lua(269) : onStartMission
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/CareerScreen.lua(209) : startSelectedGame
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/MapSelectionScreen.lua(112) : setSelectedGameMap
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/MapSelectionScreen.lua(78) : onStartClick
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/elements/ListElement.lua(367) : onDoubleClick
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/elements/GuiElement.lua(294) : mouseEvent
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/elements/BitmapElement.lua(90) : mouseEvent
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/elements/GuiElement.lua(294) : mouseEvent
D:/code/lsim2011/build/finalbin/dataS/scripts/gui/Gui.lua(236) : mouseEvent
D:/code/lsim2011/build/finalbin/dataS/scripts/main.lua(701) : mouseEvent
D:/code/lsim2011/build/finalbin/dataS/scripts/network/ObjectIds.lua(64) : table index is nil
<--end-->

This is my script:

<--script-->
DrzwiGarazowe = {};

local DrzwiGarazowe_mt = Class(DrzwiGarazowe, Object);

InitStaticObjectClass(DrzwiGarazowe, "DrzwiGarazowe", ObjectIds.OBJECT_DRZWI_GARAZOWE);

function DrzwiGarazowe:onCreate(id)
local trigger = DrzwiGarazowe:new(g_server ~= nil, g_client ~= nil);
local index = g_currentMission:addOnCreateLoadedObject(trigger);
trigger:load(id);
trigger:register(true);
--[[if g_client ~= nil then
g_client:getServerConnection():sendEvent(OnCreateLoadedObjectEvent:new(index));
end;]]

--print("created tip trigger, id: ", id);
end;

function DrzwiGarazowe:new(isServer, isClient)
local self = Object:new(isServer, isClient, DrzwiGarazowe_mt);
self.className = "DrzwiGarazowe";
self.triggerId = 0;
g_currentMission:addDrzwiGarazowe(self);
return self;
end;

function DrzwiGarazowe:load(id)

self.triggerId = id;
addTrigger(id, "triggerCallback", self);
self.playerInTrigger = false;
self.drzwilewe = getChildAt(id, 0);
self.drzwiprawe = getChildAt(id, 1);
self.koniec = 2000;
self.poczatek = 0;
self.obrotdrzwi = nil;

self.isEnabled = true;

self.DrzwiGarazoweDirtyFlag = self:getNextDirtyFlag();

return self;
end;

function DrzwiGarazowe:delete()

g_currentMission:removeDrzwiGarazowe(self);
removeTrigger(self.triggerId);
delete(self.triggerId);
DrzwiGarazowe:superClass().delete(self);
end;

function DrzwiGarazowe:readStream(streamId, connection)
if connection:getIsServer() then
if self.drzwiprawe ~= nil then
local x,y,z = getRotation(self.drzwiprawe);
y = streamReadFloat32(streamId);
setRotation(self.drzwiprawe, x, y, z);
end;
if self.drzwilewe ~= nil then
local x,y,z = getRotation(self.drzwilewe);
y = streamReadFloat32(streamId);
setRotation(self.drzwilewe, x, y, z);
end;
end;
end;

function DrzwiGarazowe:writeStream(streamId, connection)
if not connection:getIsServer() then
if self.drzwiprawe ~= nil then
local x,y,z = getRotation(self.drzwiprawe);
streamWriteFloat32(streamId, y);
end;
if self.drzwilewe ~= nil then
local x,y,z = getRotation(self.drzwilewe);
streamWriteFloat32(streamId, y);
end;
end;
end;

function DrzwiGarazowe:readUpdateStream(streamId, timestamp, connection)
self:readStream(streamId, connection);
end;

function DrzwiGarazowe:writeUpdateStream(streamId, connection, dirtyMask)
self:writeStream(streamId, connection);
end;

function DrzwiGarazowe:update(dt)

if self.playerInTrigger then
if InputBinding.hasEvent(InputBinding.GARAZ_DRZWI) then
self.obrotdrzwi = not self.obrotdrzwi;
end;
end;
if self.obrotdrzwi then
self.poczatek = self.poczatek + dt;
self.poczatek = math.min(self.poczatek, self.koniec);
else
self.poczatek = self.poczatek - dt;
self.poczatek = math.max(self.poczatek, 0);
end;
if self.drzwiprawe ~= nil then
local x,y,z = getRotation(self.drzwiprawe);
local newY = math.max(0*(3.14159265/180))*(self.poczatek/self.koniec);
setRotation(self.drzwiprawe, x, newY, z);
end;
if self.drzwilewe ~= nil then
local x,y,z = getRotation(self.drzwilewe);
local newY = math.max(0*(3.14159265/180))*(self.poczatek/self.koniec);
setRotation(self.drzwilewe, x, newY, z);
end;

--setRotation(self.drzwiprawe, 0, (110*(3.14159265/180))*(self.poczatek/self.koniec), 0);
--setRotation(self.drzwilewe, 0, (-110*(3.14159265/180))*(self.poczatek/self.koniec), 0);

end;

function DrzwiGarazowe:updateMoving(delta)
if self.drzwiprawe ~= nil and self.isServer then
local x,y,z = getRotation(self.drzwiprawe);
local newY = math.max(110*(3.14159265/180))*(self.poczatek/self.koniec);
setRotation(self.drzwiprawe, x, newY, z);
self:raiseDirtyFlags(self.DrzwiGarazoweDirtyFlag);
end;
if self.drzwilewe ~= nil and self.isServer then
local x,y,z = getRotation(self.drzwilewe);
local newY = math.max(-110*(3.14159265/180))*(self.poczatek/self.koniec);
setRotation(self.drzwilewe, x, newY, z);
self:raiseDirtyFlags(self.DrzwiGarazoweDirtyFlag);
end;
end;

function DrzwiGarazowe:draw()
if self.playerInTrigger then
if self.obrotdrzwi then
g_currentMission:addExtraPrintText("Zamknij brame: Wcisnij "..InputBinding.getButtonKeyName(InputBinding.GARAZ_DRZWI));
else
g_currentMission:addExtraPrintText("Otworz brame: Wcisnij "..InputBinding.getButtonKeyName(InputBinding.GARAZ_DRZWI));
end;
end;
end;

function DrzwiGarazowe:triggerCallback(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)

if self.isEnabled then
if onEnter then
if (g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode) then
self.playerInTrigger = true;
end;
elseif onLeave then
if (g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode) then
self.playerInTrigger = false;
end;
end;
end;
end;
<--end-->

This is photo of my trigger in GE:
http://www.abload.de/image.php?img=triggeringame4rgo.jpg

Vielen Dank im Voraus fur Ihren Hilfe. Entschuldigung aber meine Englisch Kenntnisse ist schlecht.

Wojtek Speedy (unknown) 19.01.2011 13:38
Please delete my post


Note: Log in to post. Create a new account here.