This is an old revision of the document!


How to make an onCreate for Triggers

Game Version: FS15 and later
GE Version: 6.x and later


Modding Index | Misc. Modding Tutorials


This tutorial will teach you how to make an oncreate trigger

Skill level needed too even attempt this is a little more then basic.

What will this tut teach me you ask? how to make an tip trigger? an silo? (if you gotten this far and still wonders then you do not have the needed skill level) no this tut will teach you how to do the most important thing about triggers and that is to call it.

Lets start with the basic script layout that you must have

triggerBase = {};

local triggerBase_mt = Class(triggerBase, Object);
InitObjectClass(triggerBase, "triggerBase");

function triggerBase.onCreate(id)
    local instance = triggerBase:new(g_server ~= nil, g_client ~= nil);
	if instance:load(id) then
		g_currentMission:addOnCreateLoadedObject(instance);
		instance:register(true);
	else
		instance:delete();
	end;
end;
g_onCreateUtil.addOnCreateFunction("customCallScript", triggerBase.onCreate);

function triggerBase:new(isServer, isClient)
    local self = Object:new(isServer, isClient, triggerBase_mt);
    self.className = "triggerBase";
	
    return self;
end;

function triggerBase:load(id)
	return true;
end;

function triggerBase:delete()
end;

function triggerBase:readStream(streamId, connection)
end;

function triggerBase:writeStream(streamId, connection)
end;

function triggerBase:update(dt)
end;

function triggerBase:updateTick(dt)
end;

Original Author: XX | Date: XX

Modding Index | Misc. Modding Tutorials