fix: fix crashed in old cbs system
This commit is contained in:
parent
6fa7180d7a
commit
6c91fbe9ef
8 changed files with 25 additions and 14 deletions
|
@ -81,7 +81,7 @@ end
|
||||||
-- Manage pressed keys
|
-- Manage pressed keys
|
||||||
|
|
||||||
function InputManager:flushKeys()
|
function InputManager:flushKeys()
|
||||||
for i,v in ipairs(self.sources) do
|
for i, source in ipairs(self.sources) do
|
||||||
source:flushKeys()
|
source:flushKeys()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,16 +136,15 @@ end
|
||||||
|
|
||||||
function Scene:setKeys()
|
function Scene:setKeys()
|
||||||
if (self.inputLocked) then
|
if (self.inputLocked) then
|
||||||
self.sources = core.input.fakesources
|
|
||||||
self.inputLockedTimer = self.inputLockedTimer - 1
|
self.inputLockedTimer = self.inputLockedTimer - 1
|
||||||
if (self.inputLockedTimer <= 0 ) then
|
if (self.inputLockedTimer <= 0 ) then
|
||||||
self.inputLocked = false
|
self.inputLocked = false
|
||||||
end
|
end
|
||||||
|
self.menusystem.keys = self.sources[1].fakekeys
|
||||||
else
|
else
|
||||||
self.sources = core.input.sources
|
self.sources = core.input.sources
|
||||||
|
self.menusystem.keys = self.sources[1].keys
|
||||||
end
|
end
|
||||||
|
|
||||||
self.menusystem.keys = self.sources[1].keys
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Scene:getKeys(sourceid)
|
function Scene:getKeys(sourceid)
|
||||||
|
|
|
@ -4,6 +4,7 @@ return {
|
||||||
class = "speedster",
|
class = "speedster",
|
||||||
speed = 5,
|
speed = 5,
|
||||||
jump = 3,
|
jump = 3,
|
||||||
|
turns = 3,
|
||||||
|
|
||||||
startlevel = 1,
|
startlevel = 1,
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,5 @@ return {
|
||||||
technic = 50, -- How much items & wisps will be powerfull for this character.
|
technic = 50, -- How much items & wisps will be powerfull for this character.
|
||||||
mind = 50, -- Magic defense.
|
mind = 50, -- Magic defense.
|
||||||
luck = 50, -- Critical hits and stuff like that.
|
luck = 50, -- Critical hits and stuff like that.
|
||||||
|
speed = 50, -- Où le personnage se trouve dans le tour.
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ end
|
||||||
|
|
||||||
function CharacterManager:init()
|
function CharacterManager:init()
|
||||||
for k, v in pairs(self.namelist) do
|
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)
|
local fileinfo = love.filesystem.getInfo(dir)
|
||||||
if fileinfo ~= nil then
|
if fileinfo ~= nil then
|
||||||
self:initCharacter(v)
|
self:initCharacter(v)
|
||||||
|
@ -45,7 +45,13 @@ end
|
||||||
|
|
||||||
function CharacterManager:getCharacterData(charname)
|
function CharacterManager:getCharacterData(charname)
|
||||||
-- va eprmettre de récupérer les données d'un personnage
|
-- 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
|
end
|
||||||
|
|
||||||
function CharacterManager:initCharacter(id)
|
function CharacterManager:initCharacter(id)
|
||||||
|
@ -63,7 +69,6 @@ function CharacterManager:initCharacter(id)
|
||||||
stats.technic = character.base_stats.technic
|
stats.technic = character.base_stats.technic
|
||||||
stats.mind = character.base_stats.mind
|
stats.mind = character.base_stats.mind
|
||||||
stats.speed = character.base_stats.speed
|
stats.speed = character.base_stats.speed
|
||||||
stats.turns = character.base_stats.turns
|
|
||||||
|
|
||||||
character.stats = stats
|
character.stats = stats
|
||||||
self.list[id] = character
|
self.list[id] = character
|
||||||
|
@ -131,7 +136,7 @@ function CharacterManager:getSkillList(id)
|
||||||
local character = self.list[id]
|
local character = self.list[id]
|
||||||
local learnedlist = {}
|
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
|
local tech_name, tech_level, isLearned = v[1], v[2], false
|
||||||
if tech_level <= character.stats.level then
|
if tech_level <= character.stats.level then
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ function love.load()
|
||||||
core = Core(true)
|
core = Core(true)
|
||||||
game = Game()
|
game = Game()
|
||||||
|
|
||||||
scenes.test()
|
scenes.cbs()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
|
|
@ -101,7 +101,7 @@ function Cursor:update(dt)
|
||||||
if (self.frame >= 4) then
|
if (self.frame >= 4) then
|
||||||
self.frame = 1
|
self.frame = 1
|
||||||
end
|
end
|
||||||
local keys = self.controller.keys
|
local keys = self.controller.sources[1].keys
|
||||||
|
|
||||||
if (keys["up"].isPressed) then
|
if (keys["up"].isPressed) then
|
||||||
dy = math.max(self.y - 1, 1)
|
dy = math.max(self.y - 1, 1)
|
||||||
|
|
|
@ -14,8 +14,8 @@ function Character:new(controller, x, y, charid)
|
||||||
err("FATAL ERROR: charid not set")
|
err("FATAL ERROR: charid not set")
|
||||||
end
|
end
|
||||||
self.charid = charid
|
self.charid = charid
|
||||||
self.actionPerTurn = game.characters.list[self.charid].base_stats.turns
|
self.actionPerTurn = game.characters.list[self.charid].turns
|
||||||
self.assets:addSprite(charid, "assets/sprites/characters/" .. charid)
|
self.assets:addSprite(charid, "datas/gamedata/characters/" .. charid .. "/sprites")
|
||||||
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
||||||
self:setAnimation("idle")
|
self:setAnimation("idle")
|
||||||
self:setSprite(charid, 32, 48, true)
|
self:setSprite(charid, 32, 48, true)
|
||||||
|
@ -41,6 +41,10 @@ end
|
||||||
|
|
||||||
function Character:setActive()
|
function Character:setActive()
|
||||||
local gridsize = game.characters.list[self.charid].base_stats.move
|
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.controller.cursor:setGrid("square", self.x, self.y, gridsize, self)
|
||||||
self.startx, self.starty = self.x, self.y
|
self.startx, self.starty = self.x, self.y
|
||||||
self.controller.cursor:set(self.startx, self.starty)
|
self.controller.cursor:set(self.startx, self.starty)
|
||||||
|
@ -50,6 +54,7 @@ function Character:setActive()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Character:update(dt)
|
function Character:update(dt)
|
||||||
|
self.keys = self.controller.sources[1].keys
|
||||||
if (self.currentAction == "moving") then
|
if (self.currentAction == "moving") then
|
||||||
self.xprevious = self.x
|
self.xprevious = self.x
|
||||||
self.yprevious = self.y
|
self.yprevious = self.y
|
||||||
|
@ -74,7 +79,7 @@ function Character:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif (self.currentAction == "selectAttack") then
|
elseif (self.currentAction == "selectAttack") then
|
||||||
if (self.controller.keys["B"].isPressed) then
|
if (self.keys["B"].isPressed) then
|
||||||
--self.currentAction = "selectDirection"
|
--self.currentAction = "selectDirection"
|
||||||
--self.controller.cursor:set(self.x, self.y)
|
--self.controller.cursor:set(self.x, self.y)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue