Can we run script inside entity from local disk (for testing), (Yes we can for development)


#1

Can we run a script inside entity ?
That script is stored on my local disk for testing.

If it’s not possible how do we ever need to edit and test a script ?
No do not say use the build in script editor because that one is not workable for me.

Or is there some other way to test script you want to run later inside entity ?


#2

I am also new to this and have found this way:

Store your script on your disk as normal use your favorite editor, then upload it to the assets of the sandbox using the asset browser’s blue “chose file” button.

Then you can set the entity script url like: atp:/yourscriptname.js or atp:/yourfolder/yourscriptname

If you change the file you need to upload it again and, because of caching in the interface client, you will need to edit the entity script url with a new parameter on the end like atp:/yourscriptname.js?v=x where you increment x every time.

Seems to work for me so far but I’ve not done anything complicated yet.

Cheers,
Robin.


#3

That way i know, and that is not a good way to develop a script. I still have nightmares from that 1 year ago. where one step more complex then now.

We just need to have the option to run it from disk for testing.
But still with your way the cache is going to bite !


#4

Oh, hasn’t bitten me yet, but I’m only using one asset so far :slight_smile:

I agree it’s clumsy too. Maybe the option to use file://URLs for script and then some global search and replace to set them all to proper URLs when deploying?

Cheers,
Robin.


#5

We have been thru this before several times.
There is (was) a feature available to run scripts by directly injecting the code into the scriptURL window.
This method has been broken for more than a year, sadly. Because this was the best method for testing scripts instead of uploading a fresh version everytime.

@james_hifi has confirmed that this method was available but is not currently working.
https://alphas.highfidelity.io/t/getting-nowhere-with-script-examples/10724/9


#6

I just done test, just enter instead of script url local filepath in the script url box. and i can run the script from inside the entity from local disk. :thumbsup:

Also with that way when you change the script and save it , it get automatic updated.


#7

Thats outstanding, nice way to find a workaround Richo. Of course this is not a long term solution, what you suggest isnt actually DI but a local path rather than a URL path. Good for testing but only for the host user, any other user will be looking for that script on their local computer and wont find it.

But if it works then it a time saver during testing.


#8

A remarkable lack of understanding about model, script, and other URL reference properties. Today any time a property of an entity is changed, messages are sent to other scene presences to synchronize the change. Change color, messages are sent to the scene presences. Change dimensions, messages are sent to all scene presences to synchronize with that change. Now change the script associated with the entity and the change is not communicated, change the model associated with the entity and that change is not communicated. My guess that scene presences are alerted but because stale cache entries remain, the change fails to manifest. This is why the cached entry for any URL ref based property needs to be evicted, so that the change can be seen.

Without that fundamental change there is no way to have a meaningful and efficient shared development environment. Imagine having to clear your entire cache. Imagine these people being highly paid graphic artisits and programmers having to wait 5-10 minutes every time all their caches have to be entirely cleared simply because of this flaw. Makes no sense. No business sense.


#9

Well, my head did know what i want, but my fingers changed it.
Fixt it, i just want easy test a script without reupload it. And tht seems possible and make thing much more easy !

If the script works you upload it into atp.
Would be nice if tp have directory’s for scripts, textures , sounds etc.


#10

For entity scripts, until fairly recently there was a “Reload” button associated with the script URL. If I recall correctly, this successfully reloaded the script for yourself and others in the domain. (It used a special entity property to accomplish this.) This button was removed when the refresh buttons that added “?” plus date were added to all the URLs. Actually, it wasn’t removed, I just commented it out when restyling the entities editor. The code and entity property are probably still there and should be able to be re-enabled so that a “Reload” button is available for entity scripts again.


#11

I honesty do not understand why there is so much resistance to blowing off the related cache entry whenever a script, model, etc. reference property is changed. It would eliminate the issue automatically in a domain with multiple people in it.


#12

I don’t understand it either. I’m not resisting it; just noting a feature that was there and could perhaps be reinstated for now.