void create_entity_object (entity *object, script_object_descriptor *type) {
/* create a script wrapper object and attach native object to it */
object->script_wrapped = script_new_value_of_user_type(type);
script_set_user_data(object->script_wrapped, object);
/* add a reference to the entity for the script wrapper */
ref_entity(object);
}
void ref_entity(entity *object) {
/* if we have only 0 or 1 references already, this is either a new object or a
script-owned object, and the script wrapper is unrooted, so we must root
it to prevent collection */
if (object->refs <= 1)
script_set_root(object->wrapped);
/* increment reference count */
++object->refs;
}
void unref_entity(entity *object) {
/* decrement reference count */
–object->refs;
/* if there's no more references, the object is dead, kill it */
if (object->refs == 0)
free_entity(object);
/* if there's just one reference left, only the script wrapper is keeping us alive;
unroot the wrapper so the wrapper can be collected if not in use */
else if (object->refs == 1)
script_remove_root(object->script_wrapped);
}
entity_script_gc_collection(script_value value) {
/* retrieve native object from script value */
entity *object = (entity*)script_get_user_data(value);
entity_unref(object);
}
the recent thread. As some may know, my current project is indeed entirely in Ruby,
the network is quite loosely based on Tyche's RockettMud so I am very thankful for
his work. but what I am not looking forward to is "reinventing the wheel" in the sense
that I do love ROM. I find myself just recreating many of the routines and commands in
Ruby, and it just seems sort of dumb. :tongue:
So after reading up on some of the posts, I am wondering how I could embed Ruby into
my old ROM project? My main goal would be to add OOP abilities to the current structures,
which would open the door to room scripting, as well as simplification of adding player commands.
where can I find specifics on this? I know theres been chatter of using Lua in C so is it possible to
use that documentation?
thanks, also, if anyone thinks this is a bad idea, please support your claim with constructive facts. :biggrin: