Up to Main Index Up to Journal for August, 2021 JOURNAL FOR TUESDAY 31ST AUGUST, 2021 ______________________________________________________________________________ SUBJECT: Mobiles/NPCs now use items DATE: Tue 31 Aug 19:52:10 BST 2021 Time for one last journal entry this month. The public experiment Git branch has received an update. Mobiles/NPCs now hold, wear and wield items from their inventory. This is using the Holding, Wearing and Wielding fields from the zone files. It’s taken a while to implement the feature as I needed to add a few new hooks here and there. I also wanted to keep things simple with little bookkeeping required. Mostly the hooks were for item setup and initialisation. As a result the Thing.Enable method has been renamed Thing.InitOnce and there is a new Thing.Init method. InitOnce is called only once — when an item is first loaded and placed into the world. Init is called whenever an item needs to be reset to its initial state — it’s called by InitOnce and by the state.Reset method. Currently the Init method is used to register an item’s Action event, if it has one. Init also causes a mobile/NPC to hold, wear and/or wield items from its inventory. The Thing.Unmarshal method has been cleaned up a bit. References are qualified with the zone reference during unmarshaling, instead of iterating the values of an item at the end. There is a new small wrapper function Thing.decodeInt which replaces some repetitive code. The EXAMINE command has been updated to show what items are currently being held, worn and/or wielded. The output is a little bit of a mess at the moment due to no word wrapping :( However, you can once again show off your finery from Merkle’s :) Players and mobiles/NPCs are no longer considered to be containers you can use the PUT and TAKE commands with. Next, I think I need to tidy up the output in general and maybe add colours. Formatting and folding text can hit performance quite hard. It’s not so much the formatting and folding as the handling of multi-byte Unicode, combining diacritics, non-displaying escape codes and preserving significant white-space that eats up the cycles. I have an idea I’m going to try which may simplify things — but may result in losing a little functionality. At the moment having messages such as “a little old lady sneezes.” instead of “The little old lady sneezes.” really bugs me, so I’ll be happy to get the formatting is sorted out. I’ve also been thinking about splitting up the core/commands.go file into separate files for each command — some commands are quite large now. It would be nice to have them in a separate sub-package like core/commands/get.go for instance. However, that would mean a lot of prefixing core.xxx to everything. Dot importing core would solve the issue, but dot imports are frowned upon :( In the meantime I’ll be thinking about how I’m going to implement a front-end for logins and account creation… -- Diddymus Up to Main Index Up to Journal for August, 2021