fix: fix crashed in old cbs system

This commit is contained in:
Kazhnuz 2019-08-12 12:37:00 +02:00
parent 6fa7180d7a
commit 6c91fbe9ef
8 changed files with 25 additions and 14 deletions

View file

@ -81,7 +81,7 @@ end
-- Manage pressed keys
function InputManager:flushKeys()
for i,v in ipairs(self.sources) do
for i, source in ipairs(self.sources) do
source:flushKeys()
end
end

View file

@ -136,16 +136,15 @@ end
function Scene:setKeys()
if (self.inputLocked) then
self.sources = core.input.fakesources
self.inputLockedTimer = self.inputLockedTimer - 1
if (self.inputLockedTimer <= 0 ) then
self.inputLocked = false
end
self.menusystem.keys = self.sources[1].fakekeys
else
self.sources = core.input.sources
self.menusystem.keys = self.sources[1].keys
end
self.menusystem.keys = self.sources[1].keys
end
function Scene:getKeys(sourceid)

View file

@ -4,6 +4,7 @@ return {
class = "speedster",
speed = 5,
jump = 3,
turns = 3,
startlevel = 1,

View file

@ -8,4 +8,5 @@ return {
technic = 50, -- How much items & wisps will be powerfull for this character.
mind = 50, -- Magic defense.
luck = 50, -- Critical hits and stuff like that.
speed = 50, -- Où le personnage se trouve dans le tour.
}

View file

@ -35,7 +35,7 @@ end
function CharacterManager:init()
for k, v in pairs(self.namelist) do
local dir = "datas/gamedata/characters/" .. v .. ".lua"
local dir = "datas/gamedata/characters/" .. v .. "/init.lua"
local fileinfo = love.filesystem.getInfo(dir)
if fileinfo ~= nil then
self:initCharacter(v)
@ -45,7 +45,13 @@ end
function CharacterManager:getCharacterData(charname)
-- va eprmettre de récupérer les données d'un personnage
return require("datas.gamedata.characters." .. charname)
local charfolder = "datas.gamedata.characters." .. charname
local character = require(charfolder)
character.base_stats = require(charfolder .. ".stats")
character.inventory = require(charfolder .. ".inventory")
character.skills = require(charfolder .. ".skills")
return character
end
function CharacterManager:initCharacter(id)
@ -63,7 +69,6 @@ function CharacterManager:initCharacter(id)
stats.technic = character.base_stats.technic
stats.mind = character.base_stats.mind
stats.speed = character.base_stats.speed
stats.turns = character.base_stats.turns
character.stats = stats
self.list[id] = character
@ -131,7 +136,7 @@ function CharacterManager:getSkillList(id)
local character = self.list[id]
local learnedlist = {}
for i, v in ipairs(character.skill_list) do
for i, v in ipairs(character.skills) do
local tech_name, tech_level, isLearned = v[1], v[2], false
if tech_level <= character.stats.level then

View file

@ -30,7 +30,7 @@ function love.load()
core = Core(true)
game = Game()
scenes.test()
scenes.cbs()
end
function love.update(dt)

View file

@ -101,7 +101,7 @@ function Cursor:update(dt)
if (self.frame >= 4) then
self.frame = 1
end
local keys = self.controller.keys
local keys = self.controller.sources[1].keys
if (keys["up"].isPressed) then
dy = math.max(self.y - 1, 1)

View file

@ -14,8 +14,8 @@ function Character:new(controller, x, y, charid)
err("FATAL ERROR: charid not set")
end
self.charid = charid
self.actionPerTurn = game.characters.list[self.charid].base_stats.turns
self.assets:addSprite(charid, "assets/sprites/characters/" .. charid)
self.actionPerTurn = game.characters.list[self.charid].turns
self.assets:addSprite(charid, "datas/gamedata/characters/" .. charid .. "/sprites")
self.assets.sprites[self.charid]:setCustomSpeed(16)
self:setAnimation("idle")
self:setSprite(charid, 32, 48, true)
@ -41,6 +41,10 @@ end
function Character:setActive()
local gridsize = game.characters.list[self.charid].base_stats.move
if (gridsize == nil) then
gridsize = 3
core.debug:warning("cbs/character", "move value is nil")
end
self.controller.cursor:setGrid("square", self.x, self.y, gridsize, self)
self.startx, self.starty = self.x, self.y
self.controller.cursor:set(self.startx, self.starty)
@ -50,6 +54,7 @@ function Character:setActive()
end
function Character:update(dt)
self.keys = self.controller.sources[1].keys
if (self.currentAction == "moving") then
self.xprevious = self.x
self.yprevious = self.y
@ -74,7 +79,7 @@ function Character:update(dt)
end
elseif (self.currentAction == "selectAttack") then
if (self.controller.keys["B"].isPressed) then
if (self.keys["B"].isPressed) then
--self.currentAction = "selectDirection"
--self.controller.cursor:set(self.x, self.y)
end