Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Jun 24, 2023
1 parent fbc2ad4 commit 9f8ffd6
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 63 deletions.
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export default React.memo(() => {
meta,
);
(doc as any).contents.set('Trigger', doc.createNode(Trigger));
for (const [tName, [tComment, taskComments]] of Object.entries(Trigger)) {
for (const [tName, [tComment, taskComments]] of Object.entries(
commentMap.t,
)) {
(doc.getIn(['Trigger', tName], true) as any).commentBefore = tComment;
for (let i = 0; i < taskComments.length; i++) {
(doc.getIn(['Trigger', tName, 'Task', i], true) as any).comment =
Expand Down
155 changes: 103 additions & 52 deletions src/data/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
...taskTemplate,
jsonfy: ([w, x, y, z, b, t]) => `setblock{${b},${x} ${y} ${z} ${w}} ${t}`,
parser: [
/^\s*consolecommand{([^}]+)}\s*(\S+.+)/,
([c, t]) => [
['target', t],
['command', c],
],
/^\s*setblock{([^}]+)}\s*(\S+.+)/,
([c, t]) => {
const [block, cord] = c.split(',', 2);
const [x, y, z, w] = cord.trim().split(/(?:,\s*)|(?:\s+)/, 4);
return [
['world', w],
['x', x],
['y', y],
['z', z],
['block', block],
['target', t],
];
},
],
},
'Task::damage': {
Expand Down Expand Up @@ -218,14 +226,17 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
...taskTemplate,
jsonfy: ([t, w, x, y, z]) => `teleport{${x} ${y} ${z} ${w}} ${t}`,
parser: [
/^\s*teleport{\s*(\S+)\s+(\S+)\s+(\S+)\s+([^}]+)}\s*(\S+.+)/,
([x, y, z, w, t]) => [
['target', t],
['world', w],
['x', x],
['y', y],
['z', z],
],
/^\s*teleport{([^}]+)}\s*(\S+.+)/,
([c, t]) => {
const [x, y, z, w] = c.trim().split(/(?:,\s*)|(?:\s+)/, 4);
return [
['target', t],
['world', w],
['x', x],
['y', y],
['z', z],
];
},
],
},
'Task::spawnmob': {
Expand All @@ -242,15 +253,19 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
...taskTemplate,
jsonfy: ([w, x, y, z, a, m]) => `spawnmob{${m},${a},${x} ${y} ${z} ${w}}`,
parser: [
/^\s*spawnmob{([^,]+),([^,]+),\s*(\S+)\s+(\S+)\s+(\S+)\s+([^}]+)}/,
([m, a, x, y, z, w]) => [
['world', w],
['x', x],
['y', y],
['z', z],
['a', a],
['mob', m],
],
/^\s*spawnmob{([^}]+)}/,
([t]) => {
const [m, a, c] = t.split(',', 3);
const [x, y, z, w] = c.trim().split(/(?:,\s*)|(?:\s+)/, 4);
return [
['world', w],
['x', x],
['y', y],
['z', z],
['a', a],
['mob', m],
];
},
],
},
'Task::removemobs': {
Expand All @@ -270,16 +285,21 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
jsonfy: ([w, x1, y1, z1, x2, y2, z2]) =>
`removemobs{${x1} ${y1} ${z1} ${x2} ${y2} ${z2} ${w}}`,
parser: [
/^\s*removemobs{\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+([^}]+)}/,
([x1, y1, z1, x2, y2, z2, w]) => [
['world', w],
['x1', x1],
['y1', y1],
['z1', z1],
['x2', x2],
['y2', y2],
['z2', z2],
],
/^\s*removemobs{([^}]+)}/,
([c]) => {
const [x1, y1, z1, x2, y2, z2, w] = c
.trim()
.split(/(?:,\s*)|(?:\s+)/, 7);
return [
['world', w],
['x1', x1],
['y1', y1],
['z1', z1],
['x2', x2],
['y2', y2],
['z2', z2],
];
},
],
},
'Task::checkprice': {
Expand Down Expand Up @@ -402,15 +422,24 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
jsonfy: ([w, x, y, z, t, i]) =>
`addhologram{${x} ${y} ${z} ${w},${i},${t}}`,
parser: [
/^\s*addhologram{\s*(\S+)\s+(\S+)\s+(\S+)\s+([^,]+),([^,]+),([^}]+)}/,
([x, y, z, w, i, t]) => [
['world', w],
['x', x],
['y', y],
['z', z],
['text', t],
['id', i],
],
/^\s*addhologram{([^}]+)}/,
([tt]) => {
const ttt = tt.split(',');
const t = ttt.pop() ?? '';
const i = ttt.pop() ?? '';
const [x, y, z, w] = (ttt.join(' ').trim() ?? '0 0 0').split(
/(?:,\s*)|(?:\s+)/,
4,
);
return [
['world', w],
['x', x],
['y', y],
['z', z],
['text', t],
['id', i],
];
},
],
},
'Task::edithologram': {
Expand Down Expand Up @@ -587,7 +616,7 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
'Task::taskitem::at': {
tooltip: '在背包指定位置给予目标一个物品执行器',
message0:
'给予目标 %1 一个物品执行器 %2,放入背包的 %3 位置(空间不足则强行覆盖)',
'给予目标 %1 一个物品执行器 %2,放入背包的 %3 (0-35)位置(空间不足则强行覆盖)',
args0: [
{ type: 'field_input', text: '@p', name: 'target' },
{ type: 'field_input', text: '', name: 'item' },
Expand Down Expand Up @@ -920,7 +949,7 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
},
'Data::tag': {
tooltip: '设置一个局部变量',
message0: '设置局部变量 tag.%1 为 %2 (本列内可用)',
message0: '设置局部变量 tag.%1 为 %2 (本队伍内可用)',
args0: [
{ type: 'field_input', text: '', name: 'key' },
{ type: 'field_input', text: '', name: 'value' },
Expand Down Expand Up @@ -1233,7 +1262,7 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
[t]: { Type: 'InteractBlock', Id: [`${x} ${y} ${z} ${w}`] },
}),
triggerParser: ([c]) => {
const [x, y, z, w] = (c ?? '').split(/\s+/, 4);
const [x, y, z, w] = (c ?? '0 0 0').trim().split(/(?:,\s*)|(?:\s+)/, 4);
return [
['world', w ?? ''],
['x', x],
Expand Down Expand Up @@ -1374,7 +1403,9 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
},
}),
triggerParser: ([c]) => {
const [x1, y1, z1, x2, y2, z2, w] = (c ?? '').split(/\s+/, 7);
const [x1, y1, z1, x2, y2, z2, w] = (c ?? '')
.trim()
.split(/(?:,\s*)|(?:\s+)/, 7);
return [
['world', w ?? ''],
['x1', x1],
Expand All @@ -1390,7 +1421,7 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
tooltip:
'在一名玩家进入多个指定的区域时触发。若一直在区域内,触发间隔为1秒',
message0:
'[触发器名 %1] \n 当玩家进入 %2 (x1 y1 z1 x2 y2 z2 world格式,JSON字符串数组序列化)多个区域时 (@p等可用)',
'[触发器名 %1] \n 当玩家进入 %2 (x1 y1 z1 x2 y2 z2 world格式,逗号分隔)多个区域时 (@p等可用)',
args0: [
{ type: 'field_input', text: '', name: 'trigger' },
{ type: 'field_input', text: '', name: 'cords' },
Expand All @@ -1399,11 +1430,20 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
jsonfy: ([t, c]) => ({
[t]: {
Type: 'WalkInRegion',
Id: (JSON.parse(c) as string[]).map(s => s.trim()).filter(s => s),
Id: c
.split(',')
.map(s => s.trim())
.filter(s => s),
},
}),
triggerParser: cords => [
['cords', JSON.stringify(cords.map(s => s.trim()).filter(s => s))],
[
'cords',
cords
.map(s => s.trim())
.filter(s => s)
.join(','),
],
],
},
'Sensing::WalkOutRegion': {
Expand All @@ -1428,7 +1468,9 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
},
}),
triggerParser: ([c]) => {
const [x1, y1, z1, x2, y2, z2, w] = (c ?? '').split(/\s+/, 7);
const [x1, y1, z1, x2, y2, z2, w] = (c ?? '')
.trim()
.split(/(?:,\s*)|(?:\s+)/, 7);
return [
['world', w ?? ''],
['x1', x1],
Expand All @@ -1443,7 +1485,7 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
'Sensing::WalkOutRegion::Complex': {
tooltip: '在一名玩家进入指定ID的区域时触发。若一直在区域内,触发间隔为1秒',
message0:
'[触发器名 %1] \n 当玩家离开 %2 (x1 y1 z1 x2 y2 z2 world格式,JSON字符串数组序列化)多个区域时 (@p等可用)',
'[触发器名 %1] \n 当玩家离开 %2 (x1 y1 z1 x2 y2 z2 world格式,逗号分隔)多个区域时 (@p等可用)',
args0: [
{ type: 'field_input', text: '', name: 'trigger' },
{ type: 'field_input', text: '', name: 'cords' },
Expand All @@ -1452,11 +1494,20 @@ export const blocks: Record<string, MyBlockRegisterProps> = {
jsonfy: ([t, c]) => ({
[t]: {
Type: 'WalkOutRegion',
Id: (JSON.parse(c) as string[]).map(s => s.trim()).filter(s => s),
Id: c
.split(',')
.map(s => s.trim())
.filter(s => s),
},
}),
triggerParser: cords => [
['cords', JSON.stringify(cords.map(s => s.trim()).filter(s => s))],
[
'cords',
cords
.map(s => s.trim())
.filter(s => s)
.join(','),
],
],
},
'Sensing::VexClickButton': {
Expand Down
26 changes: 17 additions & 9 deletions src/data/defaultYaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ PlayerRule:
# 1: 只有队伍内玩家可以互相看到名字。
# 2: 游戏内都能看到队伍内玩家的名字。
NameInvisible: 0
# 队伍内是否允许PVP。
# 是否允许攻击队友
PvP: false
# 玩家被药水溅射到时扔出药水的人收到的通知,none是不显示
PotionHitMessage: none
# PvP 时打人的一方收到的通知,none是不显示
PvPMessage: none
# 被箭射中时,射人的一方收到的通知,none是不显示
ProjectileMessage: none
# PvP 为 false 时,攻击队友时打人的一方收到的通知,none是不显示
PvPMessage: none # 禁止攻击队友!
# 队伍内是否允许溅射药水影响。
Potionhit: true
# Potionhit 为 false 时,药水溅射到队友时扔出药水的人收到的通知,none是不显示
PotionHitMessage: none # 禁止用药水砸队友!
# 队伍内是否允许弹射物伤害。
Projectile: true
# Projectile 为 false 时,弹射物打到队友时,射人的一方收到的通知,none是不显示
ProjectileMessage: none # 禁止射击队友!
# 是否强制队伍聊天。
ChatInGroup: false
# 是否允许携带物品进入队伍。如果关闭,背包或装备有东西的人禁止加入。
Expand Down Expand Up @@ -116,7 +116,15 @@ ControlTask:
# 队伍被加载时(服务器启动、新的脚本载入等) 一般来讲都会需要的初始化工作
- enabletrigger{all} # 激活所有触发器,一般会这样做除非你希望自定义触发器的开启时机
- midjoin{false} # 不允许中途加入游戏
Trigger: {}
Trigger:
限定玩家区域:
# 防止玩家跑出游戏区域,记得修改坐标!
Type: WalkOutRegion
Id:
- 0 0 0 10 255 10 world
Task:
- teleport{0 0 0 world} @p
- title{&c你不可以离开游戏区域!,你已被传送回来} @p
# CsgScratch 编辑器的相关信息,与 Csg 本身无关
CsgScratchMeta: '{}'`;
CsgScratchMeta: '{"ScratchPositionOfControlTask":{"onGroupLoaded":["30","60"]},"ScratchPositionOfTrigger":{"限定玩家区域":["30","310"]}}'`;
2 changes: 1 addition & 1 deletion src/data/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.0.2';
export const version = '0.0.4';

0 comments on commit 9f8ffd6

Please sign in to comment.