Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Port

Pages: 1 2 3 4 [5] 6 7 8 9 10 ... 12
62
Off Topic / I made some kind of chat site
« on: June 23, 2013, 12:43:29 PM »

63
Off Topic / Ask Port anything
« on: June 19, 2013, 06:39:08 AM »
If you can't figure out what this topic is about from the subject then you shouldn't be here, so there's really no need to put anything here.

so why did I put something up there!?
I might only respond with a PM, depending on the question


ask absolutely anything

64
Off Topic / Steam, what are you doing?
« on: June 07, 2013, 02:07:04 AM »


I'm only logged into Steam on a laptop and a phone.
Where are you getting web chat and console from?
I don't even have any console, and I've never logged into Steam on one.

65
Gallery / There is no time to explain.
« on: May 24, 2013, 09:19:18 AM »
== BEGIN TRANSMISSION (ENCRYPTION: -REDACTED-) ==

The world of Blockland is slowly being taken over. Nobody knows who will be next. It might be you. Here's an image scientists have constructed of what happens to the blockheads who have so far been affected.



I advise everyone to take extreme caution.

No, this is not the farlands.

== END TRANSMISSION ==

66
Source SDK - Developer Textures




This is a remake of the well known plain "orange developer texture" from Source as a print for ModTer bricks.
It comes with a standard orange version, a gray version and a transparent version which uses the brick color.

The prints loop perfectly and include a small "4x4" label near the top left.
Bonus for developers: Each grid square is exactly one Torque unit.




67
Going to quote this entire post because it'll clear things up a lot (this post is what this is based on):

Sometimes programming in TorqueScript can be a bit of a pain. So I had an idea a while ago for a little support script that someone could execute and it would wrap TorqueScript things into a simple interface. It works a lot like jQuery, with recursive or chaining of functions and is completely event-orientated and a tiny bit asynchronous. Here's a little bit of examples of what it can do (the global object is known as _ for quick coding, $Baseplate if you're picky):

Code: [Select]
_.on("client connect", sayHello);

function sayHello(%client) {
_(%client).message("You're now admin.").admin(true).message("Just kidding.").kick();
}

The engine is basically event-based, which means you bind a callback to an object based on a specified event and then when that object triggers that event (or "it happens") the callback is called (usually with additional arguments, depending on the event). The first bit is a function that binds the global event "client connect" to the function/callback "sayHello" (which is then defined below it). "sayHello" is passed the %client object who just connected to the server and called whenever a client connects.

Then the real magic of the recursive nature of the library starts. The first function is just the function "_", which at the moment just returns the object if it is passed an object. This is only used to signify the fact that you'll be using a baseplate chain for easier reading, and it's possible it'll be required in a future version (if there is one). You'll notice it's one big long line (and it might look a little messy like that, but you can make it look nicer by putting a new line between the dots). This is because every function that takes a value (for eg. the "message" function is a method on the client that messages a value to the client) then returns the client afterwards.

The first function messages the client telling them they're getting admin, then returns the client object, which then can be recursively used again. Then the client is made an admin (admin(isAdmin)) and then the client object is again returned. The client is then messaged saying it was a joke and then the client is returned. Then finally the client is kicked from the server. Note: all of these functions are defined by this library.

But that's just a simplistic example, there are plenty of other cool features. Note: Most methods in the library return the current value of a property of an object when no arguments are supplied, but set the property of the object to a supplied argument and then return the object if an argument is supplied.

An array class (all baseplate methods that need some sort of array thing use this):
Code: [Select]
%array = _.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
%another = _.Array(11, 12, 13, 14, 15);

%array.push(11).pop(); // add 11 to the end, then remove the last element (hence removes newly added 11)
%array.concat(%another).each(forEach); // concatenate (joins two arrays) and then return a newly joined array, but then do a foreach loop on it and calls the specified callback ("forEach") with every value in the array

function forEach(%value) { // called for each value in the array
echo(%value);
} // echos all the way between 0 and 15

echo(%another.join("\t")); // joins an array together into a string, delimited by a string value
// echos "11\t12\t13\t14\t15"

%zeros = _.Array();
%zeros.allocate(100, 0); // sets the array size to 100 and fills all elements with zero
%zeros.set(0, 1).reverse(); // sets the first element to 1 and then reverses the array, hence 1 is now the last element (the 100th element)

A platform object (and class, but it's auto instantiated) that gives you underlying connections to the player's computer. Because all of the methods are generally accessing things controlled by the computer, the only thing that takes an argument to change it's property is .clipboard and .resolution.
Code: [Select]
%platform = _.platform; // also _.Platform() or $Baseplate::Platform

echo(%platform.os()); // echoes "windows" or "macintosh", as they are the only operating system that currently work for blockland
echo(%platform.ram()); // echos the amount of ram the computer has
echo(%platform.clipboard("lol this is on the clipboard").clipboard()); // sets the clipboard and then echos the value of it, should echo what it was set to

%resolution = %platform.resolution(); // returns an array of the computer's resolution

echo(%resolution.get(0) @ ", " @ %resolution.get(1));
%platform.resolution(800, 600); // set the computer's resolution to 800 by 600.

// and others that aren't as useful

A benchmarking system for testing the speed of something (usually against another method):
Code: [Select]
function test1(%time) {
if(%time) // finished
echo("test1 took " @ %time);
else
getRandom(1, 10);
}
function test2(%time) {
if(%time)
echo("test2 took " @ %time);
else
getRandom(1, 1000);
}

// do 1000 tests of each
_.benchmark(test1, 1000);
_.benchmark(test2, 1000);

A simplified schedule system:
Code: [Select]
function callback1() {
echo("callback1 called");
}
function callback2() {
echo("callback2 called");
}

_.in(4000, callback1); // in 4 seconds after this is called, call callback1
_.every(5000, callback2); // every 5 seconds call callback2 (repeating schedule)

Extended string operations:
Code: [Select]
%string = _.string;

%string.toUppercase("dogS"); // -> DOGS
%string.charAt("bbbac", 3); // -> "a"
%string.fromCharCode(%string.charCodeAt("zed", 0)); // -> "z" (ascii map manipulation, useful for lots of things)

function tokenCallback(%token) {
echo(%token);
}

%string.tokenize("dogs:are:animals:omg", ":", tokenCallback);

Extended math operations:

Code: [Select]
%math = _.math;

echo(%math.PI);
echo(%math.PHI); // more constants too

%math.cos(3.14); // all trig in radians, just like torque
%math.atan(0.5); // this is the standard atan, torque forces atan2 on you
%math.atan2(0.5,0.5); // torque's version (works better for complex math)
%math.round(0.4); // 0
%math.radians(90); // %math.PI / 4
%math.degrees(%math.PI / 2); // 180
%math.ln(100); // natural log
%math.exp(10); // exp function
%math.random() // random value, or %math.random(min, max)
%math.fraction(10.2); // returns 0.2 (fraction part of a number)
%math.base(50, 2); // 11010 (converts from one base to another, %math.base(%value, %to [, %from = 10]);

Crypto functions:
Code: [Select]
%crypt = _.crypt;

echo(%crypt.sha1("i am laughing hahahah dogs")); // uses native sha1 algorithm in torque
// %crypt.md5("dogs are funny"); needs big number math, almost works but torque's large number handling breaks it
echo(%crypt.base64Decode(%crypt.base64Encode("ninjas are smart")); // ninjas are smart

And then other things, like working with game objects (clients, players, bricks):
Code: [Select]
%brick.pushState();
%brick.name("cat_umbrella").item(gunItem).vehicle(jeepVehicle);
%brick.popState(); // back to how it was when pushState was called

Other things I've thought about are JSON handling, XML handling, networking utilities and stuff. Is this pointless or would people actually use this library?

This is a very early implementation of a system like this. No, it hasn't been tested yet, but most if not all of the currently implemented functionality should work. Get it here: http://hostr.co/cywZA2uEyg4l

Quick list of current functions, objects, etc.:

_ (alternatively $Baseplate)
The main Baseplate object.

_([object]) (alternatively Baseplate(...))
For now, simply returns the passed object if any, _ otherwise.

_.in(delay, object, method[, ...]) (alternatively $Baseplate.in(...) - this is obvious, not writing this anymore)
Schedules method (optionally as a method of object) to be called with the specified arguments in delay milliseconds. Returns a schedule reference.

_.every(delay, object, method[, ...])
Repeats a call to method (optionally as a method of object) every delay milliseconds. Returns a repeating schedule identity.

_.cancel(reference)
Given the return value of _.in or _.every, cancels the pending call or repeating call.

_.pending(reference)
Given the return value of _.in or _.every, cancels the pending call or repeating call.

_.on(event, method)
Registers method as a callback for when event is triggered. See below for a list of events.

_.trigger(event[, ...])
Calls all callbacks defined for event with the given arguments.

_.crypto (alternatively $Baseplate::Crypto, or instanciated with _.Crypto())
Provides simple cryptography features.

_.crypto.base64Encode(value)
Returns value encoded with base64.

_.crypto.base64Decode(value)
Returns value decoded with base64.

_.crypto.sha1(value)
Returns value hashed with sha1.

_.platform (alternatively $Baseplate::Platform, or instanciated with _.Platform())
Provides access to platform information and basic configuration(?). Extremely incomplete.

_.platform.os

...

you know what forget it
I'm going to write a good, formal documentation later
just read through the code and the post at the top

yes, arrays, events, bignum math, etc. is implemented



Current event list (extremely incomplete):

  • "client connect" - triggered immediately after gameConnection::autoAdminCheck
  • "client disconnect" - triggered immediately before gameConnection::onDrop
  • "chat" - triggered immediately after serverCmdMessageSent and ...TeamMessageSent
  • "global chat" - triggered immediately after serverCmdMessageSent
  • "teamchat" - triggered immediately after serverCmdTeamMessageSent

This is extremely incomplete right now.

68
Off Topic / Recent Posts is back
« on: May 04, 2013, 04:36:18 AM »

69
Off Topic / this face
« on: May 02, 2013, 03:35:19 AM »
so I was sitting in a bus and looked out the window
there was another bus parked there with this ad on it






70
Off Topic / actually forget nevermind
« on: April 26, 2013, 02:23:58 PM »
EDIT: -snip-

this is so cool but just a little part of it can't be here
loving hell

71
Modification Help / Making an object face a point (solved)
« on: April 21, 2013, 03:37:46 AM »
I'm trying to create a line between point A and B. I have a static shape which is a cube sized 1x1x1 Torque units, which I scale on the Y axis to the distance between A and B. Then, I'm positioning it in the center between A and B. The only thing left is rotating it. How would I go about this?

72
I want to offset a point originating on the player's position based on the direction they are looking, but I don't really know how to achieve it. I did it once, but I can't remember how.

Think of it like this:
@ is the player, ~ is where they are looking. X is the result point.

..~..
.X@..
.....


..X..
..@~.
.....

73
Off Topic / What
« on: April 15, 2013, 05:32:16 PM »

74
Off Topic / Minuum
« on: April 12, 2013, 10:15:08 AM »
Minuum is an "amazing new way to type". No but seriously, this seems really cool.
http://www.youtube.com/watch?v=niV2KCkKmRw

75
Off Topic / pointless browser tabs
« on: March 22, 2013, 04:51:41 PM »
my browser tabs always end up being 10% "New Tab" or including at least one "New Tab" at the end of the list

why does this always happen

Pages: 1 2 3 4 [5] 6 7 8 9 10 ... 12