## How to make inputs of multiple type in Fuses

Fusionator
Posts: 1408
Joined: Fri Aug 08, 2014 1:11 pm
Been thanked: 14 times

### How to make inputs of multiple type in Fuses

ploveday wrote:There are two ways this is commonly done by Tools in Fusion.
Thank you for the output example, but I have a question about the reverse, how do I allow an input to be multiple types? So let's say I had a tool that always output an image, but one of the inputs could be a number OR a gradient OR an image. It seems like we always define the input type and filter possible connections accordingly, so maybe this isn't possible?

The other option I have is to have a multibutton that chooses the type for the input and a NotifyChanged hides the current input and unhides the new input, but it would be much much better if this wasn't needed.

Tilt
Global Moderator
Posts: 336
Joined: Sat Aug 02, 2014 4:10 am
Location: Munich, Germany
Contact:

### Re: [Fuse] Time Machine Modifier Fuse

It would be cool if Fusion had an "Any" input and output type that allowed you to programmatically reject connections. That way, a TimeStretcher or my Switch fuse could be inserted into both image and 3D streams. Right now you have an extra Retime3D for 3D tools. Chad has probably duplicated every tool for material workflows

Fusionator
Posts: 1408
Joined: Fri Aug 08, 2014 1:11 pm
Been thanked: 14 times

### Re: [Fuse] Time Machine Modifier Fuse

Hehe... that's actually what I really want. We have the number modifier toolset, want to use it with some material plugins. So BC3 would have material inputs for Gain, Lift, etc., but you could connect numbers to it too for uniform but animated control. But it's bugged me for the number tools too because points and numbers are so close.

Your Switch example is even better. Should be able to switch anything, right?

PeterLoveday
Fusioneer
Posts: 146
Joined: Sun Sep 14, 2014 6:09 pm
Been thanked: 16 times

### Re: [Fuse] Time Machine Modifier Fuse

ploveday wrote:There are two ways this is commonly done by Tools in Fusion.
Thank you for the output example, but I have a question about the reverse, how do I allow an input to be multiple types? So let's say I had a tool that always output an image, but one of the inputs could be a number OR a gradient OR an image.
There are a couple of options, I guess.

One is to go the same way as publish, and use REGID_InputDataType in addition to the aforementioned REGID_DataType in the FuRegisterClass() call. This is what allows Publish to do Number->Number, Point->Point etc, and also tells Fusion what input type is available for "Insert" behaviour. However this doesn't really allow for an input that can connect to more than one type after the fact. The correct type of Publish is created for a certain situation, and it is then locked to that type.

If you want an input to be capable of handling more than one type, you can give it multiple datatypes (note the extra braces required to allow multiples):

Code: Select all

	InBlah = self:AddInput("Blah", "Blah",
})

Then in Process() et al, you will need to check what you have:

Code: Select all

	local p = InBlah:GetValue(req)

if istype("Image", p) then
...
elseif istype("Number", p) then
...
end

Love, Light and Peace,
- Peter Loveday

Fusionator
Posts: 1408
Joined: Fri Aug 08, 2014 1:11 pm
Been thanked: 14 times

### Re: [Fuse] Time Machine Modifier Fuse

Whoa, that's simpler than I was expecting. Thank you, I am so excited to try this out!

Tilt
Global Moderator
Posts: 336
Joined: Sat Aug 02, 2014 4:10 am
Location: Munich, Germany
Contact:

### Re: [Fuse] Time Machine Modifier Fuse

cool!

Is there a function that allows you to reject connections? For example, to make sure that an input is of the same type as an output (or vice versa, depending on what was connected first). Or would you have to return nil in Process()?

Fusionator
Posts: 1408
Joined: Fri Aug 08, 2014 1:11 pm
Been thanked: 14 times

### Re: How to make inputs of multiple type in Fuses

Would this...

Code: Select all

   InBlah = self:AddInput("Blah", "Blah",
})
Be conceptually equivalent to this...

Code: Select all

InMask = AddInput("Blah", "Blah",
LINKID_AllowedDataType, CLSID_DataType_Image,
?

Kristof
Fusionista
Posts: 557
Joined: Thu Aug 07, 2014 1:30 pm
Been thanked: 18 times

### Re: How to make inputs of multiple type in Fuses

M'kay, I can't get this to work. I can see where the syntax is coming from--it looks similar to a ComboControl--and I think there's a "{" missing in the example posted above.

Anyway, I'm trying to make a more versatile wireless fuse:

Code: Select all

--[[--
Brutally Simple Fuse - used to wirelessly connect one
part of a composition with another.
--]]--

FuRegisterClass("UberWireless", CT_Tool, {
REGS_Category = "Fuses\\Misc",
REGS_OpIconString = "UberWire",
REG_NoBlendCtrls = true,
REG_NoObjMatCtrls = true,
REG_NoMotionBlurCtrls = true,
REG_SupportsDoD = true,
})

function Create()

INPID_InputControl = "ImageControl",
end