I have have written some JavaScript code in a script tab, and noticed some of the functions are crossed out and say ‘deprecated’ when I hover over them. For example, these functions are deprecated, among others:
Scene.loadSound()
item.setOpacity()
These are listed in the API linked to from the Script tab (by pressing the i in a circle). Is there a more updated API I should be using?
totally agree…I am trying to learn the scripting but most of the examples are depreciated and there is insufficient information to guess the new syntaxes
Please either write an updater program or provide a style guide for converting old to new
this already exists for other languages like python 2->3 convertors
@Pavel it is good to see an updated API. Thank you!
Is it possible to add examples throughout the API. As it currently reads it is hard for students (or teachers) to understand how to use the syntax. I had high school students in their third or fourth year of CS, who are used to learning from documentation, try it today and many were lost. For example, it took me a lot of playing around with the moveTo function before I realized that I have to pass in a Vector3 created using the constructor and not just the x,y,z parameters. An example would make this clearer.
Those functions like Scene.loadSound() and item.setOpacity() are marked as deprecated because the platform now uses an updated API with more modern, maintainable methods. For example, instead of Scene.loadSound() you should use Sound.load(id, callback), and instead of item.setOpacity() or getOpacity() you can directly set or read item.opacity. Other features also have new namespaces—like replacing Space.showSceneNavigation(false) with GUI.HUD.sceneNavigationVisible = false. The old methods still work for now, but it’s best to switch to the new API to ensure compatibility with future updates.