[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Making Lua lexically scoped (was: Re: Proper tail recursion)
- From: "Nick Trout" <nick@...>
- Date: Tue, 31 Jul 2001 12:38:05 +0100
----- Original Message -----
From: "Nick Trout" <nick@videosystem.co.uk>
Sorry, I got a bit ahead of myself there. I'd forgotten you dont have to use
anonymous functions in functions now:
Still would be nice to be able to to t = { function a() ... end }
This would help with the clarity of your class layout(?)
| function declare_mainship()
| local classinfo = {
| _parents = { air_physics, controllable, collidable },
| Condition = "Healthy",
| imgdir = 2.0, -- the image index
|
| rimgdir = 1.0,
| direction = 0.0, -- in degrees
| bullet_type = "bullet",
| objtype = "mainship",
| exp_timer = 0.0,
| frame_time = 70,
| layer = 1,
|
| damage = 0,
| damage_max = 10,
| recharge_rate = 0.1,
|
| VisualRep = VisualReps.newDropShip
| }
|
-- dummy ai_event
function classinfo:ai_event (self)
end
|
| -- constructor
function classinfo:new (self,a_list) -- constructor
| if (type(a_list) ~= "table") then
| print("mainship:new() called with non-table "..tostring(a_list));
| else
| a_list._parents = { self };
| a_list.key = {}; -- make our private keydown list
| a_list.ctrl_centered = 1.0;
| a_list.dest_dir = 0.0;
| end
| return a_list
| end
function classinfo:recharge (self,byWhom) -- recharge method
| local damage = self.damage;
| if (damage > 0) then
| damage = max(0,damage - recharge_rate);
| self.damage = damage;
| end
| end
|
| declare_class("MainShip", classinfo)
| end
|
|
|
|