From dd5c377144dd0800554587c9956a3ab83b2abb68 Mon Sep 17 00:00:00 2001 From: nate smith Date: Fri, 28 Apr 2023 23:52:58 -0700 Subject: [PATCH] revisit exit thoughts after break --- roadmap.md | 6 ++++++ server/witch/header.go | 12 +++++++----- server/witch/witch.go | 2 +- witch_spike.lua | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/roadmap.md b/roadmap.md index df3f10e..b34a13f 100644 --- a/roadmap.md +++ b/roadmap.md @@ -41,6 +41,12 @@ It's tempting to have the `exits` map because of its simplicity, but it actually TODO draft something new +Coming back to this after a long break, this new scheme with the exits table seems strictly worse than the tildemush approach. i don't like the amount of book keeping in the new approach--that's complexity that can lead to bugs. i think it's ultimately most elegant to just...let the exit exist in two rooms. + +aside: i want to think through why exits shouldn't be on a room but it's a pretty quick answer. i don't want rooms that aren't world editable to be un-connectable to other things. if someone comes along and makes room A and then never comes back, it should be tunnel-able to from other rooms. i like the idea of people finding some cobwebbed room and then building a ladder up to it from somewhere. + +so i'm going back to the tildemush approach. the next question is; is the exit maps a useful thing? couldn't the go handler just add a second, mirrored go handler? a handler that checks room directionality? + ## server beta - [x] grpc server diff --git a/server/witch/header.go b/server/witch/header.go index 39eef16..bbd5cc6 100644 --- a/server/witch/header.go +++ b/server/witch/header.go @@ -19,11 +19,13 @@ func witchSees(l *lua.LState) int { return addPatternHandler(l, "emote") } -func witchGo(l *lua.LState) int { - // TODO get the handler map - // - check if handler map has a Go handler already, exit early if so - // TODO register this object as an exit in DB - return addPatternHandler(l, "go") +func witchGoes(l *lua.LState) int { + // arg 0: direction + // arg 1: from room + // arg 2: to room + // TODO call addPatternHandler with "go" verb and direction pattern; figure out how to call moveSender etc + // TODO call addPatternHandler again for the reverse direction + return -1 } func witchSeen(l *lua.LState) int { diff --git a/server/witch/witch.go b/server/witch/witch.go index 2ecd42b..5d5a99f 100644 --- a/server/witch/witch.go +++ b/server/witch/witch.go @@ -130,7 +130,7 @@ func NewScriptContext(db db.DB, getSend func(string) func(*proto.ClientMessage) l.SetGlobal("has", l.NewFunction(witchHas)) l.SetGlobal("hears", l.NewFunction(witchHears)) l.SetGlobal("sees", l.NewFunction(witchSees)) - l.SetGlobal("go", l.NewFunction(witchGo)) + l.SetGlobal("goes", l.NewFunction(witchGoes)) l.SetGlobal("seen", l.NewFunction(witchSeen)) l.SetGlobal("my", l.NewFunction(witchMy)) l.SetGlobal("_handlers", l.NewTable()) diff --git a/witch_spike.lua b/witch_spike.lua index 6da85e8..203a92d 100644 --- a/witch_spike.lua +++ b/witch_spike.lua @@ -159,3 +159,35 @@ provides("give $this $money $unit", function(args) say("i need more money") end end) + +-- Example 3: a rusty door +has({ + name = "rusty metal door" + description = "it's almost fully consumed by rust but still heavy and solid feeling" +}) + +allows({ + read = "world", + write = "owner" + carry = "owner", + execute = "world", +}) + +-- option 1: fully manual + +provides("go east", function(args) + if sender.where = "gallery" then + move_sender("ossuary") + end +end) + +provides("go west", function(args) + if sender.where = "ossuary" then + move_sender("gallery") + end +end) + +-- option 2: magical helper + +-- automatically creates the two `go` handlers above +goes("east", "gallery", "ossuary")