Extention builder needed...
I need an extention that can do these two things, nothing more.
Code:
integer distance(int A, int B)
{
int AtoBforw = abs(A-B);
int AtoBback = abs(A-(B-360));
if(AtoBforw>AtoBback)
{
return AtoBback;
}else{
return AtoBforw;
}
}
integer way(int A, int B)
{
int AtoBforw = abs(A-B);
int AtoBback = abs(A-(B-360));
if(AtoBforw > AtoBback)
{
return 1;
}else if(AtoBforw < AtoBback){
return -1;
}else{
return 0;
}
}
Sorry if you don't understand it, it is meant to get the distance between two angles and the direction you need to go to get there.
Also sorry if some of my syntax is wrong, I've never programmed anything in C++ before.
Re: Extention builder needed...
Why not get the free edition of visual studio (found here) and make the extension yourself? It shouldn't be too hard to make such a simple extension (though I speak as one who has never tried to make an extension)
Re: Extention builder needed...
I don't see why you can't use Lua to do this...
Re: Extention builder needed...
looks perfectly possible to use Lua
Re: Extention builder needed...
Response:
Don't know how to install the SDK (from experiance, installing SDKs is a pain in the neck)
Don't know how to use LUA.
:P
Re: Extention builder needed...
Code:
function distance(a,b)
forw=math.abs(a-b);
back=math.abs(a-(b-360));
if(forw>back) then
return back;
else
return forw;
end
end
function way(a,b)
forw=abs(a-b);
back=abs(a-(b-360));
if(fow>back) then
return 1
else if(forw<back) then
return -1
else
return 0;
end
end
Should work.
Re: Extention builder needed...
But... Why use Lua or make an extension to do that ? It's two simple formulas that you can make directly in MMF2... O_o
If you want to be able to use it with expressions functions, use Power Function object or an equivalent.
Re: Extention builder needed...
MMF 2 doesn't handle if statements very well, and such a thing would be "easier" to do via script.
Re: Extention builder needed...
I actually like multiple ways of doing the same thing, thats where MMF really has its power <img src="/center/images/graemlins/laugh.gif" alt="" />.
Re: Extention builder needed...
Immediate If might actually be easier than that.
Re: Extention builder needed...
why even use an if? just use min(AtoBBack, AtoBforw).
Re: Extention builder needed...
Because he's not doing a min() calculation as far as I can tell.
Re: Extention builder needed...
Thanks vortex2 for the LUA script! (Now I know how to use LUA too!)
Sorry for not responding anytime sooner, I never have time to get on my computer. (School :P)
EDIT: Two things:
Is it possible to have the tab button enabled for the text box? I NEED tab to organize my programming.
And now that I have the script in the LUA object, how do I run it? The help file didn't really help me.
Thanks :P
Re: Extention builder needed...
Use the Call function action.
Re: Extention builder needed...
for example call function "Distance" with "a|b" (a and b would be your values seperated by a "|") with 1 return.
You would then get this return after calling the function through an expression.
Re: Extention builder needed...
... and how do you get the return after calling the function through an expression?
What is an 'index value'?
The new forums are wierd...
Re: Extention builder needed...
Bump... because I really need to know.