Outerra forum

Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: zzz on December 18, 2016, 10:45:29 am

Title: Function documentation
Post by: zzz on December 18, 2016, 10:45:29 am
Can we get some documentation on:

this.$ctx()

specifically on how to get the context of another Object from within a different Object.

and

this.object_test
this.add_weapon

Thanks.
Title: Re: Function documentation
Post by: cameni on December 18, 2016, 12:41:11 pm
$ctx returns the context where the object was created. this.$ctx() returns the scope through which you can access the global variables, the same ones that you'd normally access without any $ctx call. Hence, it makes no sense to use it on this, but only on references to other objects that you obtained, if you want to access their globals.

Note all this temporary and will likely go away, as it's no good usage pattern to have scripts accessing stuff arbitrarily.

Code: [Select]
    ///Test if ray from model hits an object
    //@param pos model-space position
    //@param dir model-space ray direction
    //@param maxdist max ray distance to check (keep short if possible)
    //@param exclude_self true if ray should not hit origin body
    //@param joint [optional] bone id to be relative to (with pos, rot arguments)
    //@return {$ret: object hit, norm: hit surface normal vector, hitpoint: world position}
    function object_test( pos, dir, maxdist, exclude_self, joint)

add_weapon is a dummy, does nothing yet.