diff options
author | rubidium <rubidium@openttd.org> | 2009-02-25 01:21:50 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-02-25 01:21:50 +0000 |
commit | 1ad50ce4e6ed74c8eeb89a1f2780e6ed58a72b2b (patch) | |
tree | 0955433146cc59335ddaac1d6e08eb177a9ead61 /src/3rdparty/squirrel/samples/class.nut | |
parent | 66a8c0a1325e1f8717150dc6bbe1bcb4fb458bef (diff) | |
download | openttd-1ad50ce4e6ed74c8eeb89a1f2780e6ed58a72b2b.tar.xz |
(svn r15578) -Change: unexternalise squirrel.
Diffstat (limited to 'src/3rdparty/squirrel/samples/class.nut')
-rw-r--r-- | src/3rdparty/squirrel/samples/class.nut | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/3rdparty/squirrel/samples/class.nut b/src/3rdparty/squirrel/samples/class.nut new file mode 100644 index 000000000..babe54f0b --- /dev/null +++ b/src/3rdparty/squirrel/samples/class.nut @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +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(); |