05 Mar 11, 06:24PM
|
The script requests/brainstorming thread!
|
|
06 Mar 11, 12:29AM
I finished it, but I'd really like the on-off switch. . .how would you go about putting a switch in the code?
06 Mar 11, 12:38AM
Do a check on an alias.
so: if (= $on/offswitch 1) [] [] That should get you on your way :)
06 Mar 11, 12:43AM
thanks much, I'll look into it.
I don't think cubescript uses booleans, so you would do this using something like this:
Code: bind <KEY> [ if (= $talk 1) [ talk = 0 ] [ talk = 1 ] ]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.
06 Mar 11, 01:09AM
so how would I install this, does it go directly into the code, or is it just in autoexe?
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.
06 Mar 11, 01:47AM
kk, thanks. I'll do that, and if I screw it up, i'll come back here :)
06 Mar 11, 03:55AM
Thanks, V-Man.
@Orynge, sorry, my mind gets away from me sometimes. ^^'
14 Apr 11, 09:00AM
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: Code: // 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 256Example: Code: ffract 3.141593Using powf to find 3^3.141593, the engine has to use this result in nthroot: Code: nthroot 115267 3Then part of the formula requires the engine to calculate this: Code: pow 3 115266Maybe AC could include Bignum... My brain feels like big num now.
14 Apr 11, 01:34PM
Use cases, please?
:D
14 Apr 11, 07:29PM
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
14 Apr 11, 07:39PM
Okay, okay, I got it. *cough*
:D "Looks like" sounds good enough anyway, doesn't it?
14 Apr 11, 09:02PM
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: ![]() Given an attractor of 32 (and it sort of dips down right there :S).
15 Apr 11, 02:24AM
So when the talk alias reaches -1231312414 it resets?
VenteX Wrote: WIN. personally I prefer manual labor so I hit / then delete to talk :D can't unlearn it. (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. Code: 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.
15 Apr 11, 09:42PM
15 Apr 11, 10:47PM
15 Apr 11, 11:32PM
Oh, instead of setting talk to 0 j00 subtact 1 and set it to zero. AHUAHUHAUHSUAS
16 Apr 11, 12:03AM
V-Man... I'm not sure if this is any more efficient than yours, but...
Code: nthroot = [ result (powf 2 (divf (log2 $arg2) $arg1)) ]Could it be that you're already doing this? I can't tell. (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!"
Didn't see that, oops.
Oh and $arg1 counts as an alias, but is it cheating if we use cmdbuf? (16 Apr 11, 12:03AM)Yarukinasu Wrote: V-Man... I'm not sure if this is any more efficient than yours, but... :/ 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 Code: 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. ;-) (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!" Code: 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.
Missing "=" ?
* V-Man considers making this: Code: alias / [divf $arg1 $arg2](16 Apr 11, 07:22AM)Mael Wrote: This will not work if a and b are both negative numbers, but you're on the right track. Code: 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.
17 Apr 11, 01:49AM
+f and -f!!!1
one sec- are you sure you mean copulate?
http://dictionary.reference.com/browse/copulate 0.o * Lantry shudders |
|
« Next Oldest | Next Newest »
|

![[Image: ic2q8o.jpg]](http://i55.tinypic.com/ic2q8o.jpg)
