Author |
Message |
McTwist
Global Moderator
Posts: 650
BL Name: McTwist
BL ID: 9845
|
 Script bin
This topic is for sharing scripts with the rest of the community. It may be a small piece of code or a larger one. Everything you post here will be public domain.
Now bring in your scripts!
[size=75][color=#007FFF]Stickied and fancied up. -Demian[/color][/size]
_________________ [img]http://img115.imageshack.us/img115/2213/logoqn0zp3.png[/img]
|
Fri, December 17th, 2010, 00:37 |
|
 |
McTwist
Global Moderator
Posts: 650
BL Name: McTwist
BL ID: 9845
|
 Re: Script bin
I'll start now, and bring in more myself later:
[code]function makeBar(%num, %max, %amount) { %n = mCeil((%num / %max) * %amount); %str = ""; for (%i = 0; %i < %amount; %i++) %str = %str @ (%i < %n ? "1" : "0"); return %str; }[/code] If you do this: [code]makeBar(250, 500, 6);[/code] It will return: [code]111000[/code] This can be used for loading bars. Alteration or modification is possible and easy to do.
_________________ [img]http://img115.imageshack.us/img115/2213/logoqn0zp3.png[/img]
|
Fri, December 17th, 2010, 00:39 |
|
 |
McTwist
Global Moderator
Posts: 650
BL Name: McTwist
BL ID: 9845
|
 Re: Script bin
And continues with this: [code]function loopNameObject(%name, %func) { %temp = "__TEMP_NAME_"; for (%i = 0; isObject(%name); %i++) { call(%name, %func); %name.setName(%temp @ %i); } for (%n = %i; %n >= 0; %n--) { %na = %temp @ %n; %na.setName(%name); } }[/code] It loops through all objects with the same name. Good when managing large group of objects with the same name. [code]loopNameObject(_brickName, doEventFunction);[/code] This will call doEventFunction on all objects that is named _brickName. Various checks can be made within doEventFunction if required.
_________________ [img]http://img115.imageshack.us/img115/2213/logoqn0zp3.png[/img]
|
Fri, December 17th, 2010, 00:43 |
|
 |
?
Posts: 2
BL Name: Flaw
BL ID: 2107
|
 Re: Script bin
Is this restricted to TorqueScript? If not.. [code] import random def getRandom(min, max): return random.random() * max + min [/code]
_________________ ~ BL_ID: 2107
|
Thu, March 3rd, 2011, 13:52 |
|
 |
McTwist
Global Moderator
Posts: 650
BL Name: McTwist
BL ID: 9845
|
 Re: Script bin
Yes it is. Is that Lua?
_________________ [img]http://img115.imageshack.us/img115/2213/logoqn0zp3.png[/img]
|
Sat, March 5th, 2011, 10:43 |
|
 |
DontCare4Free
Posts: 1
BL Name: DontCare4Free
BL ID: 23618
|
 Re: Script bin
No, Python. Lua's syntax is more VB-ish.
|
Sun, March 20th, 2011, 13:32 |
|
 |
McTwist
Global Moderator
Posts: 650
BL Name: McTwist
BL ID: 9845
|
 Re: Script bin
Oh yes! You're right. I've been working with Lua before, but never with Python.
_________________ [img]http://img115.imageshack.us/img115/2213/logoqn0zp3.png[/img]
|
Mon, March 21st, 2011, 13:30 |
|
|