Community Forum

Trigger Callbacks

Forum Overview >> Scripting

CategoryScripting
Created02.07.2011 20:21


Hans Müller (Unknown) 02.07.2011 20:23
Hi all,

I want to make a trigger, which is deleting a bale, once the bale enters the trigger, and that i can put a line for an other argument in it.

that is what i allready done.

print("loading stroh trigger");

modClassEventListener = {};
modClassEventListener.ModOrdner = g_currentModDirectory;

function modClassEventListener:loadMap(name)
local strohrechnen = 0

end;

function modClassEventListener:deleteMap()

end;

function modClassEventListener:mouseEvent(posX, posY, isDown, isUp, button)

end;

function modClassEventListener:keyEvent(unicode, sym, modifier, isDown)


end;

function onCreate(self, id)
print("created strohtrigger, id: ", id);
local instance = strohtrigger:new(g_server ~= nil, g_client ~= nil);
local index = g_currentMission:addOnCreateLoadedObject(instance);
instance:load(id);
instance:register(true); -- add update routine,
table.insert(modClassEventListener, instance);
end;

strohtrigger = {};

local strohtrigger_mt = Class(strohtrigger, Object);

function strohtrigger:new(isServer, isClient)

local self = Object:new(isServer, isClient, strohtrigger_mt);
self.className = "strohtrigger";

return self;
end;

function strohtrigger:bunkerCallback(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)

if onEnter then
if otherId ~= 0 then
local object = g_currentMission:getNodeObject(otherId);

if object ~= nil then
if object:isa(Bale) then

if g_currentMission:getIsServer() then
strohrechnen = strohrechnen + 1000
object:delete();
g_currentMission.missionStats.farmSiloAmounts[7] = g_currentMission.missionStats.farmSiloAmounts[7] + strohrechnen
strohrechnen = 0
end;
--elseif not object:isa(Vehicle) then -- do not delete vehicles, but everything else
--if g_currentMission:getIsServer() then
--object:delete();
--end;
end;
end;

end;
end;

end;

function modClassEventListener:update(dt)

end;

function modClassEventListener:draw()

end;

addModEventListener(modClassEventListener);

but it does not work.

what i do wrong?

Ludovic Fritz (mrludo40) 08.10.2011 12:35
hello,

I would like to know if you have a code to trigger a bale thank you


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