Script inside entity dont load new script after changing the source code


#1

@chris I have a big problerm, working on new script that is running inside entity. after some testing i have now found the problem that scripts inside entities cannot be reloaded or updated without reloging every time with your viewer. Especially not when windows don’t remember the size and position from previous time. I think the solution is by add a reload button asap in the entities editor. https://worklist.net/20466 other solutions welcome.

Note: make sure the url and script name is static and always the same with this test.

Steps.

  1. Create entity

  2. Create a script, with this code

    (function()
    {
        this.clickDownOnEntity = function(entityID, mouseEvent)
       {
            print(“click”);
       }    
    })

  3. upload the script to webspace etc. and put the script url in the entity properties -> Script url

  4. open the log screen

  5. click on the entity, the text click need to appear in the log screen.

  6. change the existing scriptm so it looks like this.

    (function()
    {
        this.clickDownOnEntity = function(entityID, mouseEvent)
       {
            print(“click 1”);
       }    
    })

  7. save the script with the same name

  8. upload and overwrite the script on the web space etc.

  9. click on the entity, the text click will appear instead of click 1

  10. relog, after relog you will see that the correct text appears when you click the entity.

What’s the best solution to fixt this problem without relogging and adjust all windows every time ? I think a reload button is the best way, so it clear cache and just don’t use the existing script anymore but instead the new one.


#2

Just did another test that proof the script is always running from cache when it’s loaded.

  1. click the prim with script it’s saying click.
  2. teleport to other domain.
  3. change in the script the print message
  4. save it , upload it etc.
  5. teleport back, and click the prim

You see that still the same message is loaded instead of checking with the content on the web. Now it’s pulling the script from the cache only becasue the filename is the same ? yuck !, you dont want to change the filename every small update. The cache need to reload the script in some way from url instead of cache when it’s changed.

Now only the question how ? a reload button would fix it for when you developing scripts for now.


#3

Hey @Richardus.Raymaker,

You can update your script link by appending a parameter: ?v=NUMBER (NUMBER = the version number).

For example:

http://www.yourdomain.com/youscriptfolder/yourscript.js

becomes:

http://www.yourdomain.com/youscriptfolder/yourscript.js?v=2

Then you can increase the version everytime you update.

Greetings,

@thoys


#4

Thanks @thoys , that works for now as temp solution.


#5

This is good for pulling a few hairs. Thoys trick seems not to work reliable today.
I really don’t know what going on, buit it seems to reuse too many times scripts i don’t want to use. 2. quick solutions, and iu need it.

  1. Reload from source button so am sure it’s not pulling things from the evil cache.
  2. or just option to disable cache complete while you are developing, so am 100% cache is not the problem.

How can you work if basic problems like this keep hanging around, that way you cannot make scripts.

I dont understand where hifi is getting the WRONG script from. It’s using a script that’s no longerr on my website. ALso after relog it’s still using the wrong script.


#6

It keeps strange, there’s some script running. thats inside entity, But that script is for a while not there anymore.

But why does it still seems to run with every mouse click ?
I just stopped all running scripts, it keeps responding on clicks.

It’s a bit early for halloween. But it feels like that :smile:


#7

@chris I found a few user errors with one cube that created the always printing text.
But it also showed a cache bug. i removed the entity with the wrong script. but after that the script still where running until i did a relog. It looks like deleted scripts dont get removed from cache.

Now i need to see why my new script is not doing anything :open_mouth:


#8

I have the same problem, it is hard updating entity scripts if there is no way of simply updating them. Especially when you are starting to learn scripting. Could there be a button near the script field in the edit entity window with reload? Or can the script editor work directly in the cache?


#9

@123.Basinsky.321 There’s a “reload” button for the entity script URL in my entities editor: http://ctrlaltstudio.com/hifi/edit

There used to be a “reload” button beside the script URL in HiFi’s entities editor too, but it got removed at some stage in favour of a different scheme for having “reload” buttons for this field plus others. However, this other scheme was subsequently removed without reinstating the original reload button. I’m thinking that the original “reload” button should be reinstated in HiFi’s entities editor sometime.

Note: Interface appears to automatically reload file:/// scripts so for development you could edit and load from local disk.


#10

That only seems to work if the script not have some error, but still if it automztic reload you sometimes mis that messsage in the log because it’s flooded with useless messages.

Also i currently do not use your edit.js it did give conflict when using HMD. also it’s not compatible with import and export functions last time i used it.

And the font where a bit smaller then the orginal edit.js. That is mabye better now.

Last problem is the missing F Key camera functionality.

High fidelity just need to implement the reload functions again. until then ?s= at the end of url


#11

@Richardus.Raymaker Import/export has been fully implemented in my entities editor. And camera functionality is intentionally excluded in favour of better user control over camera using inspect.js; however, I’ve just had a thought on some possible “F” key functionality - thanks for the reminder.


#12

Thanks, I looked at the edit.js and looks clear and works better. The only thing that will not work is the fact that if you do a change on a script you have to save it to a new name and import it to atp (or a webserver), copy the new URL and update the entity to get it to work. (because the older version script is still known in the cache) Would it be possible to clear a specific script from the cache everytime you rerun it? or would it be possible to run the script direct from a directory in windows for debugging purposes?


#13

with mesh u can after the model url add ?faerwfgqerwtqew4 and it will load the new version
so www.judasmodel.fbx becomes www.judasmodel.fbx?wefefgwrhrtrt342 (anything after the ? ) maybe that works with scripts also?


#14

The next release of High Fidelity will include a “reload” button by the entity script URL in the entities editor. (Or you can use my entities editor which already has a reload button. See: http://ctrlaltstudio.com/hifi/edit)


#15

That’s how i work all the time the sript is on the local disk because i cannot use the script editor in hifi and use the better readable notepad++ , reload the script i do by adding ? behind the url for now.

With mesh i go in the developer -> network menu and choice reload content in case @judas trick fail that i use to.