Files @ r16455:73fedf3e108b
Branch filter:

Location: cpp/openttd-patchpack/source/src/3rdparty/squirrel/samples/class.nut

translators
(svn r21185) -Update from WebTranslator v3.0:
traditional_chinese - 5 changes by josesun
finnish - 17 changes by USephiroth
german - 4 changes by planetmaker
luxembourgish - 5 changes by Phreeze
polish - 5 changes by xaxa
brazilian_portuguese - 2 changes by bmnds
russian - 5 changes by Lone_Wolf
slovak - 4 changes by marek995
spanish - 4 changes by Terkhen
vietnamese - 4 changes by nglekhoi
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
class BaseVector {
	constructor(...)
	{
		if(vargc >= 3) {
			x = vargv[0];
			y = vargv[1];
			z = vargv[2];
		}
	}


	x = 0;
	y = 0;
	z = 0;
}

class Vector3 extends BaseVector {
	function _add(other)
	{
		if(other instanceof this.getclass())
			return ::Vector3(x+other.x,y+other.y,z+other.z);
		else
			throw "wrong parameter";
	}
	function Print()
	{
		::print(x+","+y+","+z+"\n");
	}
}

local v0 = Vector3(1,2,3)
local v1 = Vector3(11,12,13)
local v2 = v0 + v1;
v2.Print();

FakeNamespace <- {
	Utils = {}
}

class FakeNamespace.Utils.SuperClass {
	constructor()
	{
		::print("FakeNamespace.Utils.SuperClass")
	}
}

local testy = FakeNamespace.Utils.SuperClass();