Unless you see an entry for a given property in the
Scripting Reference then I'm afraid it's not possible to get these properties directly.
SOLUTION 1 (Easy but Messy)
The simple solution (although tedious and error prone as you need to duplicate information) is to just have one massive table with all of the values that you need stored in a script somewhere. So you might have a script entity like this;
Script Entity: objectProperties
Code: Select all
local properties = { };
properties["cc_hidden_alcove" ] = {
replacesWall = false,
placement = "wall",
}
function getProperty(objectName, key)
if ( objectName == nil or key == nil ) then
return nil;
end
if ( properties[objectName] == nil ) then
return nil;
end
return properties[objectName][property];
end
You would only need to code in the properties you need, but you would have to make more sure whenever you change a property in a lua file, you also mirror that change in the script entity. Still, it's a fairly easy solution.
SOLUTION 2 (Better but Complicated)
This is a random off the top of my head thought which might not work (there are some issues I've thought about, but haven't thought about long enough to think if/how they can be solved). However, you should be able to define your own method in a lua script 'customDefineObject'. This method would come at the top of your first init script (before you need to use it) and would simply do the following;
Code: Select all
function customDefineObject(description)
if ( description == nil ) then
return;
end
defineObject(description);
if ( description.name ) then
gObjectProperties[description.name] = description;
end
end
So this would store all of the object descriptions in a big table that's accessible from within the 'init' scripts. The challenge is then getting that information available in the game (as the init scripts all run when the dungeon is built, but then that lua state is presumably discarded and new ones are used by the script entities). However, the log_framework has solved this before - you would have to create a door (or something similar) which generates a script_entity when it's opened (which you would do with a quick one-liner in a script entity). You would then have to generate lua code as a big long string and use the undocumented 'setSource(code)' method on a script_entity to pass the information from the dungeon building phase to the game.
There's a lot of work involved in this method and I've just posted an overview of it here. If you're seriously interested in this method because this is something you need to do a lot - let me know and I can post some more code snippets to help implement it. However, if you just need to get one or two properties of some objects, I would just go with option 1 and save yourself an hour or two of coding (or potentially a lot of hours if you're new to Lua and scripting).