The script requests/brainstorming thread!
(05 Mar 11, 03:17PM)Bukz Wrote: People might not like how spammy it gets so you may wanna code in a simple on/off switch. ;)

or just do it for certain weapons, for example, when you knife someone it will say 'you got shanked' or whatever, but for other weapons it doesn't say anything.
Thanks given by:
I finished it, but I'd really like the on-off switch. . .how would you go about putting a switch in the code?
Thanks given by:
Do a check on an alias.
so:
if (= $on/offswitch 1) [] []

That should get you on your way :)
Thanks given by:
thanks much, I'll look into it.
Thanks given by:
I don't think cubescript uses booleans, so you would do this using something like this:
bind <KEY> [ if (= $talk 1) [ talk = 0 ]  [ talk = 1 ] ]
this will allow you to press a key and toggle between 1 (on) and 0 (off)
there is also a way to save variables to saved.cfg, so it will remember your toggle after closing AC, but i don't know it.

EDIT: wow, i should really concentrate on one thing at a time.
Thanks given by:
so how would I install this, does it go directly into the code, or is it just in autoexe?
Thanks given by:
techincally, you could put your whole script into the autoexec, that is just not a smart thing to do as it will quickly get messy. You should put it into your code.
Thanks given by:
kk, thanks. I'll do that, and if I screw it up, i'll come back here :)
Thanks given by:
Thanks, V-Man.
@Orynge, sorry, my mind gets away from me sometimes. ^^'

Thanks given by:
I'd like to see a script that efficiently calculates decimal/fractional/irrational exponents; for that matter, I'd also like to see a script that efficiently calculates the nth root of a given number.
I say "efficiently" because I have a few behemoths that lumber around in my CPU for a few seconds, then spit out a semi-accurate result. Here they are, if it helps:
// ffract: estimates the fraction equivalent of a given floating-point number
ffract = [
tmp_remainder = $arg1; tmpd0 = 0; tmpd1 = 0; tmpd2 = 1; tmpc = 0; tmpn = 1
while [(&& (<= $tmpc $arg2) (<= $tmpd2 $arg3))] [
tmp_remainder = (divf 1 (-f $tmp_remainder (+ $tmp_remainder)))
tmpd0 = $tmpd1
tmpd1 = $tmpd2
tmpd2 = (+f $tmpd0 (*f $tmpd1 (+ $tmp_remainder)))
tmpn = (roundf (*f $arg1 $tmpd2))
+= tmpc 1]
result (concat (div $tmpn (GCD $tmpn $tmpd2)) (div $tmpd2 (GCD $tmpn $tmpd2)))]
// ffract (number) (iterations) (max denominator)

// powf: A ponderous attempt at decimal/irrational exponentiation
alias powf [if (isint $arg2) [pow $arg1 $arg2] [
if (< $arg2 0) [divf 1 (pow (nthroot (at (ffract (absval $arg2) 6) 1) $arg1) (at (ffract (absval $arg2) 6) 0))
] [pow (nthroot (at (ffract $arg2 6 112) 1) $arg1) (at (ffract $arg2 6 112) 0)]]]
// fpow (base) (decimal)

// nthroot: Newton's Method, sort of
alias nthroot [tmp_nroot = 2
loop i 81 [tmp_nroot = (*f (divf 1 $arg1) (+f (*f (- $arg1 1) $tmp_nroot) (divf $arg2 (pow $tmp_nroot (- $arg1 1)))))]
result $tmp_nroot]
// nthroot (degree) (base)
// nthroot 4 65536 returns 256
As you can see, combining ffract with Newton's nth root method gives rise to some numbers that the AC engine has trouble with...
Example:
ffract 3.141593
(at just a few iterations) returns "362122 115267".
Using powf to find 3^3.141593, the engine has to use this result in nthroot:
nthroot 115267 3
(attempting to find the 115267th root of 3).
Then part of the formula requires the engine to calculate this:
pow 3 115266
which the engine (and the Micro$oft Calculator as well) can't surmount.

Maybe AC could include Bignum...
My brain feels like big num now.
Thanks given by:
Use cases, please?
:D
Thanks given by:
Case: Generating a random integer with normalized distribution (as opposed to the default uniform distribution).
Most algorithms that produce this require fractional/decimal/irrational exponents.
I've found partial satisfaction in a script that looks like it's producing normalized distribution, but now reaching "true" normalization feels like a challenge I can't back down from. XD
Thanks given by:
Okay, okay, I got it. *cough*
:D
"Looks like" sounds good enough anyway, doesn't it?
Thanks given by:
Yeh...
Like I said, it's now a challenge I can't back down from.
I made a script to test my attempts at distribution. It takes a row of cubes in a map and treats it like a number-line, raising a cube on each "number" every time it comes up in a run of random numbers.
My latest and best attempt looks like this:
[Image: ic2q8o.jpg]
Given an attractor of 32 (and it sort of dips down right there :S).
Thanks given by:
(06 Mar 11, 12:54AM)Lantry Wrote: ...
bind <KEY> [ if (= $talk 1) [ talk = 0 ]  [ talk = 1 ] ]
...

bind <KEY> [ talk = (- 1 $talk) ]
my way of doing it ;)
Thanks given by:
So when the talk alias reaches -1231312414 it resets?
Thanks given by:
VenteX Wrote:
bind <KEY> [ talk = (- 1 $talk) ]
my way of doing it ;)

WIN. personally I prefer manual labor so I hit / then delete to talk :D
can't unlearn it.
Thanks given by:
(05 Mar 11, 02:29AM)ChaoticToSayTheLeast Wrote: Killzones. Land in an area and die. Make spike/lava/tar pits that WORK. Fall into a hole and die. Stuff like that.

Requires 1105.

x 4
y 4
z 4
die 0

deathpit [
            if (= (getposition 0) $x) [die (+ $die 1)] [];
            if (= (getposition 1) $y) [die (+ $die 1)] [];
            if (= (getposition 2) $z) [die (+ $die 1)] [];
            if (= $die 3) [die 0; suicide] []
            ]

Loop it for practicality, bind it for testing.

Also, if you create a die alias for each axis, you can define areas/volumes that kill the player.
Thanks given by:
(15 Apr 11, 03:12AM)Gibstick Wrote: So when the talk alias reaches -1231312414 it resets?

Nope :)

When $talk is 1, 1 - $talk = 0
When $talk is 0, 1 - $talk = 1
Thanks given by:
(15 Apr 11, 04:01AM)Mael Wrote: Also, if you create a die alias for each axis, you can define areas/volumes that kill the player.

OMFG BEST GEMA TOOL EVAR! :-D
Thanks given by:
Oh, instead of setting talk to 0 j00 subtact 1 and set it to zero. AHUAHUHAUHSUAS
Thanks given by:
V-Man... I'm not sure if this is any more efficient than yours, but...

nthroot = [ result (powf 2 (divf (log2 $arg2) $arg1)) ]

Could it be that you're already doing this? I can't tell.
Thanks given by:
(15 Apr 11, 11:32PM)Gibstick Wrote: Oh, instead of setting talk to 0 j00 subtact 1 and set it to zero. AHUAHUHAUHSUAS

You must've misunderstood the original equation; it's 1 minus talk, not talk minus 1

"Coming up next on VenteX's CubeScript MindF***s: swapping the numeric contents of two aliases without creating an extra one!"
Thanks given by:
Didn't see that, oops.

Oh and $arg1 counts as an alias, but is it cheating if we use cmdbuf?
Thanks given by:
(16 Apr 11, 12:03AM)Yarukinasu Wrote: V-Man... I'm not sure if this is any more efficient than yours, but...

nthroot = [ result (powf 2 (divf (log2 $arg2) $arg1)) ]

Could it be that you're already doing this? I can't tell.

:/ Well, I'm trying to get "nthroot" so that I can make a reliable "powf" script. Using your method, they'd loop forever and you'd have to pull the plug on your computer just to get it to stop. XD
powf = (stuff using nthroot)
nthroot = (stuff using powf)

To phrase it differently...

That's great! So efficient! Can you think of an efficient script for "powf"?



@Gibstick: The engine doesn't treat the args like aliases per se... You can nest simultaneous scripts that all use $arg1, for example, and one doesn't necessarily affect the content of another script's $arg1. Usually. Muahahah.
Also, cmdbuf is much like this.
To really get around having to use an alias, I'd use (keybind) on an open key... If I can find one. ;-)
Thanks given by:
(16 Apr 11, 01:45AM)VenteX Wrote: "Coming up next on VenteX's CubeScript MindF***s: swapping the numeric contents of two aliases without creating an extra one!"

a 2
b 3

alias swap [
               a (* $a $b);
               b (/ $a $b);
               a (/ $a $b)
]

Didn't bother testing it.

Edit: Holy fuck, 2:28 AM and I got it right. New usertitle.
Thanks given by:
Missing "=" ?
* V-Man considers making this:
alias / [divf $arg1 $arg2]
Have a nice sleep. :D
Thanks given by:
(16 Apr 11, 07:22AM)Mael Wrote:
a 2
b 3

alias swap [
               a (* $a $b);
               b (/ $a $b);
               a (/ $a $b)
]

This will not work if a and b are both negative numbers, but you're on the right track.

a 2
b 3

alias swap [
               a (+ $a $b);
               b (- $a $b);
               a (- $b $a)
]

Fixed :)

* VenteX wants to copulate more minds. Maybe he should get started on his long-planned CubeScript based map gen- you know what, I'll let that wait.
Thanks given by:
+f and -f!!!1
Thanks given by:
one sec- are you sure you mean copulate?
http://dictionary.reference.com/browse/copulate
0.o
* Lantry shudders
Thanks given by: