RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
991 stars 175 forks source link

:angel: Script: Log meaningful error upon callback mixup. #3081

Closed ohlidalp closed 8 months ago

ohlidalp commented 10 months ago

One point for @Xploder98 in a friendly Devs vs. Users match :)

Long story short, Xploder mixed up callbacks and the game obligued which resulted in script failure with error asCONTEXT_NOT_PREPARED. This hapenned because our callback system is very confusing:

Changes made:

Example AngelScript.log if you mix up the callbacks:

13:03:15: spawnObject(): Specifying event handler function in `game.spawnObject()` is obsolete and only works with terrain scripts; Use `eventCallbackEx()` with event `SE_EVENTBOX_ENTER` instead, it provides the same data and works with any script. Just pass an empty string to the `game.spawnObject()` parameter.
13:03:15: Warning: a callback function with signature 'void eventCallback(int, string, string, int)' was not found but a function with given name exists: 'void eventCallback(int, int)' - did you make a typo in arguments?

What needs to be tested:

CuriousMike56 commented 9 months ago

Tested: Truckshops ✅ Races ✅ Demo script ✅ Road editor ✅ Script editor ✅

Only new warning I've seen is on the "GPU benchmark" terrain (Benchmark.zip) where every tree spawned shows: [RoR|Script|Notice] Warning: a callback function with signature 'void e(int, string, string, int)' was not found The script still works as normal.