Execute a single function over several frames
Version: 2.0
Price: $20


- Now compatible with ShiVa 2.0.
- Plugin API compiled for Mac and Linux in addition to Windows : it will provide API completion in the Script module in ShiVa Editor for each of these operating systems.
- Now uses a user token instead of an email to activate

- Optimized for ShiVa 1.9.2

- JPThread.create now takes the parameters of the function.


JPThread is another magic pack, allowing you to think your game conception in a new manner. It allows you to execute the code of a function over several frames.

JPThread.create ( this.preloadSceneResources ) function MyAIModel.preloadSceneResources ( ) for i = 0, table.getSize ( this.tTextures ( ) ) - 1 do local sTextute = table.getAt ( this.tTextures ( ), i ) application.forceResourceToStayLoaded ( sTexture, application.kResourceTypeTexture, true ) JPThread.addYieldPoint ( ) end end

As a result, the loading process will be executed over several frames, at a speed of 1 texture loading per frame. Your game execution will be much more fluid. JPThread.addYieldPoint ( ) mean the function execution pauses here and will start from here at the next frame. Of course, you can add this call several times in your function code.

Here is a screenshot of the Performance Reporter in ShiVa, you can see clearly that the function does not create a freeze at all as it is executed over several frames:

JPThread performance comparison

This feature is also very useful in many other cases, think for instance how you currently load a file into the cache. Now, you will be able to do the whole process with a single function call:

function MyAIModel.loadFile ( sFile, sUrl ) cache.addFile ( sFile, sUrl ) while ( cache.getFileStatus ( sFile ) >= 0 and cache.getFileStatus ( sFile ) < 1 ) do JPThread.addYieldPoint ( ) end local nStatus = cache.getFileStatus ( sFile ) if ( nStatus == 1 ) then --Success else --Fail end end

This pack is really powerful.