Skip to content

Commit

Permalink
perf: 不再强求必须有tSkillData
Browse files Browse the repository at this point in the history
  • Loading branch information
X3ZvaWQ committed Feb 17, 2024
1 parent 54c8e8e commit 4ef7eb5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jx3box/jx3-skill-parser",
"version": "0.0.4",
"version": "0.0.5",
"description": "A package used to parse jx3 game skill script",
"authors": [
"x3zvawq <x3zvawq@gmail.com>"
Expand Down
8 changes: 4 additions & 4 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export class SkillParser {

await this.lua.doFile('/lib/load-file.lua');

let max_level = 0;
const skill_data = this.lua.ctx.env.tSkillData;
if (!skill_data) {
throw new Error('Lua解析出错,获取tSkillData时');
if (skill_data) {
max_level = skill_data.$detach().size;
skill_data.$destroy();
}
const max_level = skill_data.$detach().size;
skill_data.$destroy();

if (options.level <= 0) {
options.level = max_level;
Expand Down
6 changes: 2 additions & 4 deletions test/debug.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { SkillParser } from '../dist/index.js';
import fs from 'fs/promises';

const parser = await SkillParser.create();
const content = await fs.readFile(
'/d/games/SeasunGame_unpack/std/scripts/skill/装备/输出通用附魔减疗加伤害.lua',
);
const content = await fs.readFile('./test/jianpo.lua');

console.log(await parser.parse(content, { level: 11 }));
console.log(await parser.parse(content));

0 comments on commit 4ef7eb5

Please sign in to comment.