YOUR ACCOUNT

Login or Register to post new topics or replies
James
James
Posts: 676
Filters: 46
So far I haven't tried using arrays in a script and I wanted to use one in a function, however the following code returns a error, any reason why?

Code
function prepare()
end;

function mat4({r1,r2,r3,r4})
    local matrix = {}
    matrix[1], matrix[2], matrix[3], matrix[4] = r1, r2, r3, r4
    return matrix[1], matrix[2], matrix[3], matrix[4]
end

function get_sample(x, y)
   return mat4({1.0,0.5,0.25,1})
end;


I'm using FF3, perhaps this is due to the version I am using or maybe a limitation in map scripts? or hopefully just an error in my code.

When using an array in the prepare function it seems to work though.

Code
function prepare()
   matrix = {1.0,0.5,0.25,1.0}
end;

function get_sample(x, y)
   return matrix[1],matrix[2],matrix[3],matrix[4]
end;
  Details E-Mail
_Agentslimepunk
Posts: 2
Filters: 7
Code
function prepare()

end;

function get_sample(x, y)
   -- Image generation code goes here.

   mat4(1.0, 0.5, 0.25, 1)
   local r = matrix[2]
   local g = matrix[3]
   local b = matrix[2] + y
   local a = 1
   return r, g, b, a
end;

function mat4(r1, r2, r3, r4)
   matrix = {r1, r2, r3, r4}
   return matrix

end;


Is this basically what you were after?
  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,531 Posts
+36 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

24 unregistered users.