aboutsummaryrefslogblamecommitdiff
path: root/examples/oop_example.lua
blob: 712387b48739a402653893aaf7de80692edc8977 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                              
p = nerv.Point(0, 0) -- create a Point instance
print(p)
print(p:norm()) -- get 2-norm of the Point
p:set_x(1.0)
p:set_y(2.0)
print(p:norm()) -- get 2-norm of the Point

p = nerv.BetterPoint(1, 2)
print(p)
print(p:norm()) --get 1-norm of the Point

-- create a subclass using lua
local EvenBetterPoint = nerv.class('nerv.EvenBetterPoint', 'nerv.BetterPoint')
bp = nerv.EvenBetterPoint(1, 2)
print(p:norm())