YOUR ACCOUNT

Login or Register to post new topics or replies
Ramlyn
Ramlyn

Posts: 2930
Filters: 691
I was trying to make a Curve Switch.
It may sound a very simple thing, but I have no experience in scripting and my switch is not working well.

So....
If I start from a switch for map inputs, as the one below :

function prepare()
end;

function get_sample(x, y)
local r, g, b, a
local value = math.floor(get_sample_grayscale(x, y, SELECTOR)*5+.001)
if value == 0 then r, g, b, a = get_sample_map(x, y, INPUT01) end
if value == 1 then r, g, b, a = get_sample_map(x, y, INPUT02) end
if value == 2 then r, g, b, a = get_sample_map(x, y, INPUT03) end
if value == 3 then r, g, b, a = get_sample_map(x, y, INPUT04) end
if value >= 4 then r, g, b, a = get_sample_map(x, y, INPUT05) end
return r, g, b, a
end;

How would this change in case of curve inputs?
  Details E-Mail
Indigo Ray
Adam

Posts: 1442
Filters: 82
I'm not sure what you already know, so...

There is a curve switch component, but maybe you need this as part of a script.
Use the curve script component, not the map script component.
When you create the inputs with the input editor, it tells you how to call each input.

If the script runs but doesn't look right, maybe you have a logic error somewhere. Example: is the script calculating 'value' as you intended?

Tip: Instead of writing 'if...then...end' a bunch of times, you can use 'elseif' and 'else' (see the Lua manual)
  Details E-Mail
Ramlyn
Ramlyn

Posts: 2930
Filters: 691
Thanks Indigo Ray. I already know almost nothing. I'm simply trying to understand how it works.

What I would like to do is a Curve Switch with more than the 12 inputs of the standard one.

Possibly, I would prefer not to go much far away from the structure of the previous simple switch, otherwise I may not be able to easily change it later.

Then......
As first, a curve doesn't use r,g,b,a. I should change it with c.
Could it be something like :
if value == 0 then c = get_sample_curve(x, y, INPUT01) end
?

The grayscale input can be ok for the selector of the switch?
Should I also add t, or x and y are enough?
As return values, I saw that in other scripts are used c, c, c, 1.
But I'm not sure.
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,533 Posts
+38 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

14 unregistered users.