How would you do a value range? like.. the value can only be between -1 and 1![]()
Ah, that looks terrific!Everybody look at the Wiki page. http://www.garrysmod.com/wiki/?title...xpression_Gate
I'm working on a wiki page for the expression gate. As you can see I am writing a guide to the gate. Please help improving![/b]
(Especially "Syranide = God")
Yes, the expression gate is clocked using an external pulser instead of an internal as is the case with the CPU.Basically, I would hook it up to a pulser to simulate a frequency variable. It would check if the frequency was true, so if I had a ticktime of .001, it would have a frequency of 1000.
That's the reason I wanted to see if Input1 == 1 -> Input2 == 1 -> Out = 1; would work. So I can make something like
~Frequency ->
*rest of the Expression code*
To simulate the Frequency variable on the CPU.
Nevermind...[/b]
The way I do is like you describe there, although Frequency is slighty misleading because it implies a value... but anyway, yes that's how you do it if you would like it to run 1000 times per second, just know that the it is not possible to do it because the wirelib does not support it, I think you can do something like 50 per second at most (and there would be no reason to do otherwise either because no other component can work faster), a simple way of setting it up is using a timer instead as clock, as it would then update as fast as possible I believe.
And doing ~Clock would only update it when the clock has updated meaning that it won't speed up if the other inputs are changed.
How would you do a value range? like.. the value can only be between -1 and 1![]()
How would you do a value range? like.. the value can only be between -1 and 1[/b]
or even simplerCode:Value < -1 -> Value = -1; Value > 1 -> Value = 1;
which is the same asCode:Value = clamp(Value, -1, 1)
I suggest the second, the others as just given as examples.Code:Value = max(-1, min(1, Value))
Cheers!
I have found a VERY useful tool if you guys like to use the expression gate for formulas
Currently im using it to tweak the power stroke of a racing machine.
[attachment=381:MathGVgraph.png]
heres a link:
[attachment=382:mgv3_1.zip]
Hi, is there an code that negates a value?
Also, how do I do a greater than / less than gate?
Thanks!
Negate: (Simple arithmetic)Hi, is there an code that negates a value?
Also, how do I do a greater than / less than gate?
Thanks![/b]
Greater than: (C will be 1 if A is greater than and 0 otherwise)Code:A = -A
In terms of a the code for creating an actual greater than gate it would beCode:C = A > B
Hope it helps, just ask if you have any more questions!Code:Inputs: A B Outputs: Out Out = A > B
Thank you very much, so simple now Iv seen it.
But about The greater than gate, I just want something with a Value Range but outputs 1 if its between it and 0 if its not in the value range.
Cheers![]()
thats an is in range(inclusive) gate (exists under comparison)
and would be
Code:Inputs:Min Max Value Outputs: Out Out = ((Value < Max && Value > Min) ? 1:0)
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Super Easy Wire Download
Aha!
Hmm perhaps I should add this to the available functions, anyway, I don't want to be picky, but I want to show people how you can do it in the "intended way", that is now using (B ? 1 : 0) which is the same as just writing B (and yours is exclusive):
inclusive in-range gate (minimal version)
Code:Inputs:Min Max Value Outputs: Out Out = Value => Min && Value <= Max
Yah and a very Simple Delta is this:
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>
N@Simple Delta
I@A
O@O
O = $A
</div>
http://tiny.cc/OMFGWTFBBQ
Best People On Wiremod!
Black Phoenix, Azrael, Jat Goodwin, Magos Mechanicus, ITSBTH, Fizyk, g33v3s,tuusita, InfectiousFight, ief015
Pointless things that are pointless, are pointlessly pointless, therefore pointlessness is pointless.
So pointlessly pointing out the pointlessness of this pointless signature is utterly pointless.
My IQ is 123
Bookmarks