YOUR ACCOUNT

Login or Register to post new topics or replies
GeorgeR
Posts: 18
As a map script, this produces an incorrect result. Change r to 3 in the remapSample function to see what it should look like. Using FF 3.0.

Code

r = 3

function prepare()
end;

function remapSample(x, y)
   return (x * r) % 1, (y * r) % 1
end;

function get_sample(x, y)
   r, g = remapSample(x, y)
   return r, g, 0
end;
  Details E-Mail
Dmitry Sapelnikov
Filter Forge, Inc. AKA Egret
Posts: 76
Filters: 5
Declare the r and g variables in get_sample() as local.
The get_sample() function doesn't work well because it accidentally overrides the global r variable.

The original code:
Code
function get_sample(x, y)
   // here you rewrite the global r = 3
   r, g = remapSample(x, y)
   return r, g, 0
end;


The fixed code:
Code
function get_sample(x, y)
   // this will work correctly
   local r, g = remapSample(x, y)
   return r, g, 0
end;
  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
+31 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

29 unregistered users.