Fusion : OnCreate.scriptlib

After struggling to get this code pasted on a fusion forum without said forum’s text editor trying to ‘fix’ my text (even in a code box, seriously IP.Board, get your shit together!), i decided it was just easier to post it here and link to my own site. Whatever, more clicks for me i guess.

Anyway, it’s an extremely simple example on an OnCreate event scriptlib workaround (i’m sure it will break in many foreseen and unforeseen ways)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
while composition == nil do
 
-- wait around
end
 
globals.ev = AddEventSuite("Composition")
 
function initializeTool(tool)
tool:SetData("Initialized", 1)
print("This seems to be a newly created tool, do stuff")
end
 
function ev:OnActivateTool(event)
local tool = comp.ActiveTool
if tool == nil then
-- Yup, deselecting fires OnActivateTool, don't ask me why...
self:Default(event)
return
end
 
if tool:GetData("Initialized") ~= 1 then
initializeTool(tool)
else
print("Not a new tool, nothing to be besides filling the Console with this message, over and over and over.")
end
 
self:Default(event)
end
Share

Leave a Reply

Your email address will not be published. Required fields are marked *