MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / SaveSpellScript

Function SaveSpellScript

internal/spells/admin.go:56–72  ·  view source on GitHub ↗
(spellId string, content string)

Source from the content-addressed store, hash-verified

54}
55
56func SaveSpellScript(spellId string, content string) error {
57 spec := GetSpell(spellId)
58 if spec == nil {
59 return fmt.Errorf("spell %q not found", spellId)
60 }
61
62 scriptPath := spec.GetScriptPath()
63
64 if content == "" {
65 if err := os.Remove(scriptPath); err != nil && !os.IsNotExist(err) {
66 return fmt.Errorf("removing spell script: %w", err)
67 }
68 return nil
69 }
70
71 return util.WriteFile(scriptPath, []byte(content), 0644)
72}

Callers 1

apiV2PutSpellScriptFunction · 0.92

Calls 4

WriteFileFunction · 0.92
GetSpellFunction · 0.85
GetScriptPathMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected