Entities and Scripts


I have not been able to run any script that I put into an entity since arriving. I’ve tried several of the examples - concentrating on those that involve clicking or hovering on the object. I’ve searched the forum and found when the case had been inadvertently changed in those given in the docs and verified that I’m not having that problem. I’ve searched my logs for some indication of what I might be doing wrong but nothing. Is there something I’ve missed when starting the server?


if you copy and Save this script as a .js file on your local HD

// addEntity()

var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));  
var properties = {
  type: “Box”,
  position: position,
  color: { red: 200, green: 0, blue: 0 }    
Ent = Entities.addEntity(properties);
print(“Entity added”);

Now go to top menu of Interface FILE > Running Scripts
SEE Load Scripts Section

'from Disk’
and Navigate to were you saved the file

see https://docs.highfidelity.com/docs/running-scripts-in-interface


Here is a script for touch on entity : http://business.ozblog.me/scripts/changeColorOnClickDown.js

Create a cube, go in edit, choose the box and open the entity window. Put the scriptURL in the script field ->:

Click on the cube and it changes the color.


Of course, I woke this morning realizing that my original post is flawed - I shouldn’t have posted so late at night :slight_smile: I do have one entity running a script and it does work some/most of the time :smiley: (jsstreamplayerdomain-zone-entity.js) but it doesn’t involve me clicking on it. Also, I did go to the sandbox last night and rezzed a ball then put a script in it but still it wouldn’t work for me.

Ritzo, the addEntity script I had run before and that works fine. I tried it again this morning just to be certain after updating both the domain-server and interface. Thank you, though.

Your example exposes my problem, Summer. I tried the script you provided both ways - putting the URL in the Script URL window and then in a different entity, pasting the entire script into it but neither do anything for me. If I had another machine to check it with I would. I did notice in the docs it mentions clicking “ok” after pasting the script or URL but look as I may, I haven’t found an ‘ok’ button. I have hit the ‘reload’ button next to it and even closed and reopened the properties tab to make sure the script was still there, though.

If anybody would like to come to auralia just to click and make sure they work for you, you’re more than welcome.


@Barry, I was at auralia, have clicked at the sphere and at the cube, but nothing has happened.


well…that makes me feel better, I think. At least it’s not just my interface. Of course, it could still mean it is “ME” :smiley: I’ll be back in world in a bit but have opened it up so that anybody should be able to create and edit. Maybe if you have another moment you could create one with a touch script for me and see if it works for you. If so, then I know it is me :smiley:

I am of course assuming that this line from the docs is outdated and that clicking on the ‘edit’ button (which is not the top button) isn’t necessary to ‘click’ an entity. If there is something I’m supposed to turn on to ‘click’ items in world, I’m not seeing it :wink:

“The top button is the on/off switch. Turn on to enable click/selecting of entities.”


Thank you for the visit, Summer :slight_smile: That script worked so it seems that most every example (from the docs) I was trying to use was not downloading for me today - although when I paste the URL into a web browser, they were available. Strange.

I did try again to paste the entire script into the Script URL window (which I thought was to be the most certain way ) but that still isn’t working. Since I finally found the log, I suppose I now need to know if this is significant :smiley :smiley:

[DEBUG] [09/26 17:10:49] NOT CONSTRUCTOR
[DEBUG] [09/26 17:10:49] SCRIPT: “file:///”

Initially, I tried pasting directly from a web page but noticed the html entities that were being included so then opened vi, pasted it there then copied and pasted back to the Script URL window but still no luck.

Anyway…time for a break! At least you helped me take one step forward :slight_smile:


There is a bug currently that causes some click actions to not work,
this.mousePressOnEntity does not currently work,

I have reported this a week ago but its still a problem.

What I am interested is to know if @summer4me… does this click script that you posted work for you?


I have copied it and put the script in my own dropbox. This has worked fine. The original link I have tried yesterday and it also for me hasn’t worked. It seems, that it doesn’t load from this place.


@Barry The “not constructor” error you’re encountering for your entity script means that the script doesn’t have the particular syntax required of an entity script. See: https://docs.highfidelity.com/docs/attaching-a-script-to-an-entity . Note the parentheses surrounding the whole script, and the “function(){” and corresponding “}”. Also note that the script you’re trying to load may be local to your hard drive (“file:///”) whereas it (probably) needs to be loaded on the Web.


All my entity scripts are currently giving Not Constructor error and suggesting "SCRIPT: “file:///” whether it is local, hosted or direct inject, so something is bugged.

All my touch scripts are currently borked, and I cant get the simple changeColorOnClickDown.js working either via URL or direct.


this script

when placed in entity Script URL field

  • works for me v3229 on win 8.1