Skip to content

Commit

Permalink
fix: 修复 .sn 指令可以修改内部变量的问题 (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
MintCider authored Dec 13, 2024
1 parent 1a75601 commit b299d71
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 193 deletions.
6 changes: 5 additions & 1 deletion dice/ext_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ var ErrGroupCardOverlong = errors.New("群名片长度超过限制")
func SetPlayerGroupCardByTemplate(ctx *MsgContext, tmpl string) (string, error) {
ctx.Player.TempValueAlias = nil // 防止dnd的hp被转为“生命值”

v := ctx.EvalFString(tmpl, nil)
config := ctx.GenDefaultRollVmConfig()
config.HookFuncValueStore = func(ctx *ds.Context, name string, v *ds.VMValue) (overwrite *ds.VMValue, solved bool) {
return nil, true
}
v := ctx.EvalFString(tmpl, config)
if v.vm.Error != nil {
ctx.Dice.Logger.Infof("SN指令模板错误: %v", v.vm.Error.Error())
return "", v.vm.Error
Expand Down
Loading

0 comments on commit b299d71

Please sign in to comment.