@Abadrausar: Sounds like a really nice VM, but I need a VM that seamlessly integrates with
Go, as that is the language Rubble is written in. I had three choices:
- go-lua: Which has decent documentation and mirrors the API of the reference implementation of 5.2
- gopher-lua: Which has a not so helpful readme, but no code documentation, and does not mirror the standard API.
- Some kind of binding to the C version (of which there are several): Which all have problems with error handling (Go doesn't like longjump or C++ exceptions), and all of which are harder to use due to memory management issues between Go and C code.
go-lua was what I was planning to use, but I ran into bugs in the VM. I have the binding rewritten to use gopher-lua, so I'm back on track now.
@Dirst: Please don't use @IF_CODE. It will be going away in Rubble 7 because running scripts in slightly more complicated there (you need to tell Rubble what language the script is in), plus Rhino (the current scripting language) is going away, so everything that uses @IF_CODE would have to be rewritten anyway. Did you look at the second version I uploaded (same link as the first version)? That definitely checked for material existence (it also had more stuff wrapped in templates than the first version did, including the wyrms AND secrets).
Is every valid object automatically a shared object?
Nope. Just objects which are wrapped in a call to SHARED_OBJECT, SHARED_CREATURE, SHARED_INORGANIC, SHARED_MATERIAL_TEMPLATE, SHARED_PLANT, or SHARED_ITEM. All the stuff in the standard base (and the First Landing base) are properly wrapped, so there is no need to worry about standard materials being wrapped. SHARED_OBJECT is one of the fundamental parts of the Rubble template system, so it is fairly important to wrap all creatures, inorganics, material templates, plants, and items wherever possible. See, SHARED_OBJECT allows you to replace an object with a new one, add stuff to the end of an existing object, and do things based on whether a named object exists (among other things), so it is very handy to have. I did not wrap anything in the addon I gave you because I was feeling lazy :p (that and wrapping creatures is difficult to do properly, in your case it would require rewriting most of the caste templates to some extent).
In Rubble 7 news:
I hacked together a quick utility to convert Rubble 6 addon.meta files to the new Rubble 7 format (JSON), so addon porting is going faster now. The Rubble 7 template library will also have some new string handling templates, namely @STR_UPPER, @STR_LOWER, @STR_TITLE, and @STR_TO_ID. These templates should make certain kinds of user templates much easier to write.
I am making a concerted effort to provide templates for as many common actions that used to require scripts as possible, so an extended version of @IF that supports more operations than equality may be in the cards
JavaScript is being stubborn, the VM I am using is designed to be simple, but sometimes it is
too simple. For example the only way to export a data structure is via an autogenerated interface that uses Go's reflection library. This means that I have no way to limit what scripts can do, and conversely I have no way to automagically convert byte slices into strings and vice versa like the Lua API does. This means that data structure access will all have to be done by functions, no handy "direct access" to the underlying objects and arrays like the Lua API does. Trying to use the autogenerate interfaces for everything would be like trying to export everything with GenII in the old Rhino API, eg powerful, but hard to use and with lots of potential to machine-gun your foot
I may post a few "prerelease" version of Rubble 7 before the next DF version, but 7.0 won't be going live until shortly after next time Toady gives us a new toy