Scripting Getting Started 2017


#1

Any suggestions on getting started with this?

I found these example scripts (quite complex for getting started)

Javascript API Reference (is this obsolete and should I believe it?)

Found this category in the wiki (old or useful?)
https://wiki.highfidelity.com/wiki/Category:JavaScript_API

Is there any introduction in video format or people that meet regularly to discuss how to do this?

Thanks!


#2

There isnt any uptodate spec, unfortunately, and even some scripts are out of date. Most of the time, I’ve had to dig around the source code to get most of the info out for what is supported, and what is doable: Some of them I’ve compiled into my own framework and library.

Otherwise, best source is to talk with us here on the forums.

Here is a thread I have about scripting, if you have some experience with programming/ scripting / js

We did have javascript meets every now and then. I wonder if we should have another one someday this week.


#3

Perhaps what we need is an update on the latest scripting APIs with annotations on their limits/bugs. It is something that could be produced automatically aka doxygen or other similar interface auto-documenting frameworks.


#4

I would love to meet up any time, just let me know. Does anyone have an example of an absolutely simple call to move one of the avatars limbs… say raise an arm up in the air or something like that?


#5

I suggest looking up an archive-script called crazy legs. It makes the legs move silly procedurally using a sine on a quaternion. More recent one that isnt archived (which should work, havent tested the crazy legs for a while), is the chair script

A simpler method to play back an existing animation such as using MyAvatar.overrideRoleAnimation or MyAvatar.overrideAnimation


#6

The wiki entries for the javascript api are rather incomplete.

For instance until I added some a few days ago there was no mention of the Menu api stuff.

As far as I can tell, they are “accurate”, as in, the methods described there exist and work as described, but it’s possible mistakes have crept in. They are however as I said, incomplete.

On a side note, atleast for the client side (interface) scripting i made a quick bit of code to dump available Objects and methods to the console.

thing = {};
for (name in this) {
	var nam = name.toString();
	thing[nam] = Object.getOwnPropertyNames(this[name]);
}
print(JSON.stringify(thing));

The output


#7

See also the script, currentAPI.js, included in High Fidelity.


#8

When loaded, it crashes Interface.


#9

So it does! It used to work not so long ago. I’ve entered a bug report about it crashing Interface.


#10

I noted it on Dang crash reports a few days ago. wonders what the cause would be.


#11

It seems to be something to do with typeof for me.

I tried wrapping it in a try catch and printing every line taht it typeof’s to the log immeadiatlym try catch ddin’t help, but it crashes after the steam stuff, (atleast for me).


#12

currentAPI.js crashes when trying to reflect Steam.isRunning. Until this is fixed, here’s a modified copy of currentAPI.js that works around the problem: http://ctrlaltstudio.com/downloads/hifi/scripts/currentAPI.js


#13

Yaay… thanks David, I was going to look at that script but is just another thing on a long list.