From bd3fe0cac583739bc0d7c4b5c8f301bb350abca0 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Fri, 30 Aug 2019 00:19:31 -0400 Subject: Renamed lib to deps so github will ignore it for language stats --- deps/sol2/examples/source/player_script.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 deps/sol2/examples/source/player_script.lua (limited to 'deps/sol2/examples/source/player_script.lua') diff --git a/deps/sol2/examples/source/player_script.lua b/deps/sol2/examples/source/player_script.lua new file mode 100644 index 0000000..c53a8d1 --- /dev/null +++ b/deps/sol2/examples/source/player_script.lua @@ -0,0 +1,29 @@ +-- call single argument integer constructor +p1 = player.new(2) + +-- p2 is still here from being +-- set with lua["p2"] = player(0); below +local p2shoots = p2:shoot() +assert(not p2shoots) +-- had 0 ammo + +-- set variable property setter +p1.hp = 545; +-- get variable through property getter +print(p1.hp); + +local did_shoot_1 = p1:shoot() +print(did_shoot_1) +print(p1.bullets) +local did_shoot_2 = p1:shoot() +print(did_shoot_2) +print(p1.bullets) +local did_shoot_3 = p1:shoot() +print(did_shoot_3) + +-- can read +print(p1.bullets) +-- would error: is a readonly variable, cannot write +-- p1.bullets = 20 + +p1:boost() -- cgit v1.2.3