How does the geck do math calculations

Post » Tue May 17, 2011 2:03 am

In this formula:

set x to (75 - 1.5 (50 - 25))

Is it calculated as:
a) (75 - 1.5(25)) => (75 - 37.5) => 37.5 (btw this is the result i want so please tell me how to write this properly)
B) (75 - 1.5 * 50 - 25) => 73.5 * 50 - 25 => 3675 - 25 => 3650

In other words, can you control the sequence by the ()? or is
1) 75 - 1.5*50-25
2) (75 - 1.5)(50-25)
3) 75 - (1.5 * 50) - 25
the same?

I ask because of the way AND and OR is handled, in that OR sequences are lumped together such that (A & B) OR (C & D) is actually A and (B OR C) & D regardless of the ().

EDIT:
and is ((GetRandomPercent +1) / 50) + ((Player.GetAV Survival) / 50) going to do:
1) (GetRandomPercent + 1) first; then
2) divide the result by 50; then
3) add the result to (Player.GetAV Survival)/50
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Tue May 17, 2011 12:15 pm

In this formula:

set x to (75 - 1.5 (50 - 25))

Is it calculated as:
a) (75 - 1.5(25)) => (75 - 37.5) => 37.5 (btw this is the result i want so please tell me how to write this properly)
B) (75 - 1.5 * 50 - 25) => 73.5 * 50 - 25 => 3675 - 25 => 3650


The Geck uses the usual concept: * / % precede + - and brackets are used to override.
But I don't think you can omit the *, even in normal (pen&paper) math it would be wrong without a variable.

75 - 1.5 * (50 - 25) = 37.5


I ask because of the way AND and OR is handled, in that OR sequences are lumped together such that (A & B ) OR (C & D) is actually A and (B OR C) & D regardless of the ().


That'd be rather strange, where did you get that?

Unless they've broken it deliberately in FNV, the script language uses the common C++ operators and precedence list.

( )
!
* / %
+ -
> < >= <=
== !=
&
|
&& AND
|| OR

Of course you have to keep in mind that (A & B ) OR (C & D) is a mix of logical and boolean operators...

e.g. A=13, B=7, C=4, D=6

A & B = 5
C & D = 4

(A & B ) OR (C & D) = 1
(A & B ) | (C & D) = 5



EDIT:
and is ((GetRandomPercent +1) / 50) + ((Player.GetAV Survival) / 50) going to do:
1) (GetRandomPercent + 1) first; then
2) divide the result by 50; then
3) add the result to (Player.GetAV Survival)/50


Yes, and the result should be a number between 1 and 4
User avatar
Harry Hearing
 
Posts: 3366
Joined: Sun Jul 22, 2007 6:19 am

Post » Tue May 17, 2011 5:07 am

Hey JOG, thanks again!

http://geck.gamesas.com/index.php/Category:Conditions the link on the A & B OR C & D thing though i see now it referred to conditions on Perk Entry Points and maybe not in scripts?
the OR checkbox is used to determine how a Condition Item is evaluated with the ones that follow it. Consecutive ORs are treated like a single block when evaluating and have order precedence over AND. For example, the Condition Items (A AND B OR C AND D) are evaluated as (A AND ( B OR C) AND D) and not ((A AND B) OR (C AND D)).
By applying the distributive and other properties complex expressions can be converted into a list of Condition Items that will evaluate as intended. For example, the expression ((A AND B) OR (C AND D)) can be represented as the list of Condition Items (A OR B AND B OR C AND A OR D AND B OR D). As described above, this evaluates as ((A OR B) AND ( B OR C) AND (A OR D) AND ( B OR D)) which is equivalent to the initial expression.


EDIT: ER...its converting ( & B to the cool emoticon and i dont know how to make it not do that lol
User avatar
Vicki Blondie
 
Posts: 3408
Joined: Fri Jun 16, 2006 5:33 am

Post » Tue May 17, 2011 11:21 am

Hey JOG, thanks again!

http://geck.gamesas.com/index.php/Category:Conditions the link on the A & B OR C & D thing though i see now it referred to conditions on Perk Entry Points and maybe not in scripts?


Yes, that only applies to the "Or"-checkbox in conditions for dialogue, perks, effects etc. It's not fully obvious how to use it once you have multiple conditions. It has nothing to do with scripts.
User avatar
Sheila Esmailka
 
Posts: 3404
Joined: Wed Aug 22, 2007 2:31 am

Post » Tue May 17, 2011 3:22 am

I see this has already been resolved, but thought it might still be useful to mention that I've written an http://cipscis.com/fallout/tutorials/operators.aspx, which includes a table of operator precedence.

On a side note, you can disable emoticons by opening the post options (click the "Click to configure post options" button beneath your post when using the full editor) and unticking the "Enable emoticons?" box.

Cipscis
User avatar
Rudi Carter
 
Posts: 3365
Joined: Fri Sep 01, 2006 11:09 pm

Post » Tue May 17, 2011 11:53 am

cipsis, that's will be a great help to me (those times i understand them that is :D).ill also be sure to check the other links in your sig. thanks!
User avatar
Stryke Force
 
Posts: 3393
Joined: Fri Oct 05, 2007 6:20 am

Post » Tue May 17, 2011 9:19 am

Duplicate thread at newvegasnexus. YMMV, but once I see the same topic in both forums, I stop reading it, because it is too hard to follow.
User avatar
Marcia Renton
 
Posts: 3563
Joined: Fri Jan 26, 2007 5:15 am

Post » Tue May 17, 2011 9:41 am

@davidallen
just saw your reply at the nexus forums. thanks for taking the time! :tops:
User avatar
Joanne Crump
 
Posts: 3457
Joined: Sat Jul 22, 2006 9:44 am


Return to Fallout: New Vegas