revisit exit thoughts after break

trunk
nate smith 2023-04-28 23:52:58 -07:00
parent 31af07f7e7
commit dd5c377144
4 changed files with 46 additions and 6 deletions

View File

@ -41,6 +41,12 @@ It's tempting to have the `exits` map because of its simplicity, but it actually
TODO draft something new 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 ## server beta
- [x] grpc server - [x] grpc server

View File

@ -19,11 +19,13 @@ func witchSees(l *lua.LState) int {
return addPatternHandler(l, "emote") return addPatternHandler(l, "emote")
} }
func witchGo(l *lua.LState) int { func witchGoes(l *lua.LState) int {
// TODO get the handler map // arg 0: direction
// - check if handler map has a Go handler already, exit early if so // arg 1: from room
// TODO register this object as an exit in DB // arg 2: to room
return addPatternHandler(l, "go") // 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 { func witchSeen(l *lua.LState) int {

View File

@ -130,7 +130,7 @@ func NewScriptContext(db db.DB, getSend func(string) func(*proto.ClientMessage)
l.SetGlobal("has", l.NewFunction(witchHas)) l.SetGlobal("has", l.NewFunction(witchHas))
l.SetGlobal("hears", l.NewFunction(witchHears)) l.SetGlobal("hears", l.NewFunction(witchHears))
l.SetGlobal("sees", l.NewFunction(witchSees)) 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("seen", l.NewFunction(witchSeen))
l.SetGlobal("my", l.NewFunction(witchMy)) l.SetGlobal("my", l.NewFunction(witchMy))
l.SetGlobal("_handlers", l.NewTable()) l.SetGlobal("_handlers", l.NewTable())

View File

@ -159,3 +159,35 @@ provides("give $this $money $unit", function(args)
say("i need more money") say("i need more money")
end end
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")