Hello everyone.
Very happy to tell that due to the invaluable help of the Defold community, my game has progressed far ahead in space. It is now almost 40% complete and if I work hard(that’s not so easy ) it might be in beta soon.
So while progressing ahead, I found some thing:
I have a player controller, much similar to GBRAusers as I mentioned before. I integrated it with a Lua Module, which is something like this:
ocal M = {}
local player_ships =
{
{
category = "normal",
level1 = {
speed = 100,
turn_speed = math.rad(200),
fire_rate = 0.45,
min_speed = 50,
health = 10,
guns = 1
},
level2 = {
speed = 115,
turn_speed = math.rad(215),
fire_rate = 0.40,
min_speed = 50,
health = 11,
guns = 1
},
level3 = {
speed = 130,
turn_speed = math.rad(225),
fire_rate = 0.35,
min_speed = 50,
health = 12,
guns = 2
}
},
}--etc, etc.
This is perfectly fine , as the function in this module returns the table correctly.
But when I link it to my player script:
self.max_speed = self.ship.level1.speed
This works but this doesn’t:
self.ship = player_data.return_planedata(SHIP_NO)
if LEVEL == 3 then
self.max_speed = self.ship.level3.speed
self.speed = self.ship.level3.speed
self.health = self.ship.level3.health
self.MAX_ROTATION_SPEED = self.ship.leve13.turn_speed
self.RATE_OF_FIRE = self.ship.level3.fire_rate
self.MIN_SPEED = self.ships.level3.min_speed
end
end
It stops working and throws an error:
/Scripts/Player/Player.script:101: attempt to index field 'leve13' (a nil value)
Why is it so? Maybe am I missing some thing again?