JPPackLoader

JPPackLoader

Tool to load the packs available on this site into your games
Version : 1.6
Price : Free

Downloads

Changelog

v1.6

  • Optimized for ShiVa 1.9.2

v1.5

  • onLoadPack parameters changed: "onLoadPack" ( sPackName, sPackURI )
  • You can now know what packs have been loaded by using the new JPPackLoader table: application.getCurrentUserAIVariable ( "JPPackLoader", "tLoadedPacks" )

v1.4

  • Fixed a bug with custom local paths

v1.3

  • It is now possible to use a custom path to load the local packs, thanks to this new handler (must be called before onLoadLocalPacks): "onSetLocalPath" ( sPath )

v1.2

  • The process to find the local packs is now more accurate.

v1.1

  • New handler "onLoadLocalPacks" to automatically load all of the local packs. Very useful when adding a new pack or if a new version of a pack is available: nothing to do change in the code!
  • Fixed an issue when downloading a distant pack with "onLoadPack"

API

user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadLocalPacks" ) user.sendEventImmediate ( hUser, "JPPackLoader", "onSetLocalPath", sPath ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPack", sPackName, sPackURI ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPacksEnd" ) --User notification events: "onPacksLoadingDidEnd"

Description

JPPackLoader is an AIModel that will allow you to load .stk files in your games. It will be useful for all packages offered below.

Once the AIModel is added to your game, the process to add a pack to your game is as follows:

  • Add the .stk files you want to load to the root directory of your ShiVa project.
  • Send an event to JPPackLoader.
  • Activate your packs

Here is an example of loading and activation, with the JPAnimation pack (who must have been placed in your project root directory):

local hUser = application.getCurrentUser ( ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadLocalPacks" ) JPAnimation.activate ( "", "" )

Note that if the pack is stored locally, you can use the pack directly because it is loaded instantly when "onLoadLocalPacks" is called. However, some games may require to store the pack on a distant server, so the pack has to be downloaded and this process may take several frames. JPPackLoader is able to do it, and this is now a 2 steps process: download request made by you to JPPackLoader, and callback event sent to you by JPPackLoader when all the packs have been downloaded and are ready to be used. Here are the steps to follow:

local hUser = application.getCurrentUser ( ) user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPack", "JPAnimation", sUrl ) --Parameters are and --Do the same to request the download of any other pack here user.sendEventImmediate ( hUser, "JPPackLoader", "onLoadPacksEnd" ) --Tell JPPackLoader that all the download requests have been made to allow it to send the callback event when they all are downloaded

Simply send the "onLoadPacksEnd" event to inform JPPackLoader that all the pack requests have been made. JPPackLoader will notify you when they are all downloaded and ready to use with the "onPacksLoadingDidEnd" handler. You can start using your packs in this handler, starting with the activation:

function MyAIModel.onPacksLoadingDidEnd ( ) JPAnimation.activate ( "", "" ) end