New functions:
Added the following functions:
New functions:
Bugfix:
Sound related functions moved to a new 'JPSound' pack with tons of new features :)
You can now set default values to a new table instance:
Optimized for ShiVa 1.9.2 New function:
New functions:
Bugfix on hud.getSpinnerRotation, last rotation was 360 instead of 0.
New functions:
Parameters changed for function: hud.sizeComponentToFitText ( hComponent )
New functions:
Fixed a bug with the pack constants, that sometimes became nil in ShiVa Editor only. Fixed a bug with lists and hud_setComponentText.
Input related funtions splitted to create JPInput.
New functions:
New functions:
New constants:
JPExtendedAPI.kLoadSuccess
JPExtendedAPI.kLoadErrorLocalStorageNotFound
JPExtendedAPI.kLoadErrorCurrentUserEnvironmentDoesNotExist
JPExtendedAPI.kLoadErrorCurrentUserEnvironmentCorrupted
JPExtendedAPI.kLoadErrorUnknown
JPExtendedAPI.kSaveSuccess
JPExtendedAPI.kSaveErrorNoLocalStorageDevice
JPExtendedAPI.kSaveErrorNoLocalStorageWriteAccess
JPExtendedAPI.kSaveErrorNoLocalStorageSpaceAndCanOpenStorageManager
JPExtendedAPI.kSaveErrorNoLocalStorageSpaceAndCannotOpenStorageManager
JPExtendedAPI.kSaveErrorLocalStorageDeviceChanged
JPExtendedAPI.kSaveErrorLocalStorageDeviceRemoved
JPExtendedAPI.kSaveErrorUnknown
The xml.getElementFirstChildWithNameAndAttributes, xml.getElementFirstChildWithNameAndAttributesAndAttribute and xml.getElementFirstChildWithNameAndAttributesAndAttributeAndAttribute have been merged into a single function: hChild = xml.getElementFirstChildWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 )
The xml.getElementNextSiblingWithNameAndAttributes, xml.getElementNextSiblingWithNameAndAttributesAndAttribute and xml.getElementNextSiblingWithNameAndAttributesAndAttributeAndAttribute have been merged into a single function: hChild = xml.getElementNextSiblingWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 )
New function to get the indexes and the count of children of an xml element with a specific name and with specific attributes: nCount, tIndexes = xml.getElementChildCountWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 )
New functions: bFound = system.findFilesMatching ( tResult, sDirectory, sMatching ) --Work as the default system.findFiles, but allows to match a specific pattern. bFound = system.findDirectoriesMatching ( tResult, sDirectory, sMatching ) --Work as the default system.findDirectories, but allows to match a specific pattern.
Removed the following functions:
Added the following function for joypad sensors access:
Added the following functions for events management:
JPExtendedAPI.setCustomEventManagementEnabled ( bEnabled )
application.cancelEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.cancelObjectEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.cancelUserEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.pauseEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.pauseObjectEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.pauseUserEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.resumeEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.resumeObjectEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
application.resumeUserEvents ( sAIModelPatternToMatch, sHandlerPatternToMatch )
object.cancelEvents ( hObject, sAIModelPatternToMatch, sHandlerPatternToMatch )
object.pauseEvents ( hObject, sAIModelPatternToMatch, sHandlerPatternToMatch )
object.resumeEvents ( hObject, sAIModelPatternToMatch, sHandlerPatternToMatch )
user.cancelEvents ( hUser, sAIModelPatternToMatch, sHandlerPatternToMatch )
user.pauseEvents ( hUser, sAIModelPatternToMatch, sHandlerPatternToMatch )
user.resumeEvents ( hUser, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.cancelEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.cancelObjectEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.cancelUserEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.pauseEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.pauseObjectEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.pauseUserEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.resumeEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.resumeObjectEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
scene.resumeUserEvents ( hScene, sAIModelPatternToMatch, sHandlerPatternToMatch )
--JPExtendedAPI JPExtendedAPI.activate ( sUserToken, sActivationKey ) --NEW API FUNCTIONS: Note that you can use these function using both api.function ( ) or JPExtendedAPI.api_function ( ). Only the second case will have code completion. --animation animation.setCurrentAnimation ( hObject, nBlendLayer, sAnimation ) --application application.closeCurrentUserScene ( ) bOK, kLoadDetails = application.loadCurrentUserEnvironmentCompliant ( sName ) JPExtendedAPI.kLoadSuccess JPExtendedAPI.kLoadErrorLocalStorageNotFound JPExtendedAPI.kLoadErrorCurrentUserEnvironmentDoesNotExist JPExtendedAPI.kLoadErrorCurrentUserEnvironmentCorrupted JPExtendedAPI.kLoadErrorUnknown bOK, kSaveDetails = application.saveCurrentUserEnvironmentCompliant ( bOverride ) JPExtendedAPI.kSaveSuccess JPExtendedAPI.kSaveErrorNoLocalStorageDevice JPExtendedAPI.kSaveErrorNoLocalStorageWriteAccess JPExtendedAPI.kSaveErrorNoLocalStorageSpaceAndCanOpenStorageManager JPExtendedAPI.kSaveErrorNoLocalStorageSpaceAndCannotOpenStorageManager JPExtendedAPI.kSaveErrorLocalStorageDeviceChanged JPExtendedAPI.kSaveErrorLocalStorageDeviceRemoved JPExtendedAPI.kSaveErrorUnknown application.setMinFrameRate ( nFrameRate ) application.setMaxFrameRate ( nFrameRate ) --hashtable hashtable.push ( htHashtable, sKey, vValue ) metatable = hashtable.toMetatable ( htHashtable ) htHashtable = hashtable.fromMetatable ( metatable ) sString = hashtable.queryString ( htParams ) --hud hud.setButtonText ( hComponent, vText ) hud.setCheckText ( hComponent, vText ) hud.setEditText ( hComponent, vText ) hud.setLabelText ( hComponent, vText ) hud.setListItemTextAt ( hComponent, vText, nItem, nColumn ) hud.setComponentText ( hComponent, vText, nOptListItem, nOptListColumn ) hud.setComponentTextWithVariableTextHeight ( hComponent, vText, nNormalTextHeight, nMinTextHeight ) bYes = hud.getComponentIntersectsComponent ( hComponent0, hComponent1, bOptPermissive ) nMaxLineCount = hud.getComponentMaxVisibleLineCount ( hComponent ) nTextHeight = hud.getComponentTextHeightToMatchLineCount ( hComponent, nLineCount ) nRatio = hud.getComponentRatio ( hComponent ) nSizeX, nSizeY = hud.getComponentSizeInvariant ( hComponent ) nSizeX, nSizeY = hud.getComponentSizeVariant ( hComponent ) hUser = hud.getComponentUser ( hComponent ) nRayPntX, nRayPntY, nRayPntZ, nRayDirX, nRayDirY, nRayDirZ = hud.getCursorRay ( hUser ) nRayPntX, nRayPntY, nRayPntZ, nRayDirX, nRayDirY, nRayDirZ = hud.getPointRay ( x, y ) nAngle = hud.getSpinnerRotation ( nRotationBySecond, nAngleCount ) bYes = hud.isComponentAtPoint ( hComponent, x, y ) bYes = hud.isComponentUnderCursor ( hComponent ) bYes = hud.isEqualTo ( hComponent, hOtherComponent ) hud.postCallAction ( hUser, nDelay, sAction, vParam0, vParam1, vParam2, vParam3 ) hud.setComponentBackgroundImageMiddleUVOffset ( hComponent, nUVX, nUVY ) hud.setComponentBackgroundImageContainerSpaceUVOffset ( hComponent, nOffsetU, nOffsetV ) hud.setComponentBackgroundImageContainerSpaceUVScale ( hComponent, nScaleU, nScaleV ) hud.setComponentBackgroundImageScreenSpaceUVOffset ( hComponent, nOffsetU, nOffsetV ) hud.setComponentBackgroundImageScreenSpaceUVScale ( hComponent, nScaleU, nScaleV ) hud.setComponentOrigin ( hComponent, kOrigin, bKeepScreenSpacePosition ) hud.setComponentPosition ( hComponent, nOptX, nOptY ) hud.setComponentStrechableBackground ( hComponent, sTexture, nStrechUVX, nStrechUVY, nStrechCoefSizeX, nStrechCoefSizeY, nOptSpriteUVX, nOptSpriteUVY, nOptSpriteUVSX, nOptSpriteUVSY ) hud.setContainerRotation ( hComponent, nRotation ) hud.sizeComponentToFitText ( hComponent ) x, y = hud.transformPointFromInput ( x, y ) hud.translate ( hComponent, nTx, nTy ) --hud (screen space related functions) x, y = hud.getComponentScreenSpaceBottomCenter ( hComponent ) x, y = hud.getComponentScreenSpaceLeftCenter ( hComponent ) x, y = hud.getComponentScreenSpaceRightCenter ( hComponent ) x, y = hud.getComponentScreenSpaceTopCenter ( hComponent ) nSizeX, nSizeY = hud.getComponentScreenSpaceSize ( hComponent ) hud.setComponentScreenSpaceBottomLeftCorner ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceBottomRightCorner ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceCenter ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceTopLeftCorner ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceTopRightCorner ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceBottomCenter ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceLeftCenter ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceRightCenter ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceTopCenter ( hComponent, nPositionX, nPositionY ) hud.setComponentScreenSpaceSize ( hComponent, nSizeX, nSizeY ) --input nRayPntX, nRayPntY, nRayPntZ, nRayDirX, nRayDirY, nRayDirZ = input.getCursorRay ( hUser ) nRayPntX, nRayPntY, nRayPntZ, nRayDirX, nRayDirY, nRayDirZ = input.getPointRay ( x, y ) x, y = input.transformPointFromHud ( x, y ) --math nMin = math.min ( nValue0, nValue1, nValue2, ... ) nMax = math.max ( nValue0, nValue1, nValue2, ... ) nResult = math.sum ( nValue0, nValue1, ... ) --object object.destroy ( hObject ) sTag = object.getTag ( hObject ) bYes, nAngle = object.isLookingAtPoint ( hObject, nPointX, nPointY, nPointZ, kSpace, nMaxAllowedAngle ) object.lookAtObject ( hObject, hOtherObject, nOptFactor, nOptOffsetY ) object.setRotation ( hObject, nOptRX, nOptRY, nOptRZ, kSpace ) object.setTag ( hObject, sTag ) object.setTranslation ( hObject, nOptTX, nOptTY, nOptTZ, kSpace ) --scene scene.close ( hScene ) sCollisionType, vHitObject, nHitDist, nHitID, x, y, z, i, j, k = scene.getFirstHit ( hScene, nRayPosX, nRayPosY, nRayPosZ, nRayDirX, nRayDirY, nRayDirZ, nRayLength ) --string sFolder, sFile, sExtension, sParameters = string.explodePath ( sPath ) sChar = string.getAt ( sString, nIndex ) sChar = string.getFirst ( sString ) sChar = string.getLast ( sString ) sSubString = string.getSubStringWithDelimiter ( sString, sDelimiter, nPosition ) sString = string.setByte ( sString, nIndex, nByte ) --system bFound = system.findFilesMatching ( tResult, sDirectory, sMatching ) bFound = system.findDirectoriesMatching ( tResult, sDirectory, sMatching ) nHours, nMinutes, nSeconds = system.getClock ( ) nHoursAngle, nMinutesAngle, nSecondsAngle = system.getClockAngles ( nOptHours, nOptMinutes, nOptSeconds ) sUnixTimestamp = system.getUnixTimestampStringForDate ( nYear, nOptMonth, nOptDay, nOptHours, nOptMinutes, nOptSeconds ) bYes = system.isYearBissextile ( nYear ) --table bFound, tIndexes = table.find ( tTable, vValue ) nIndex = table.findFirst ( tTable, vValue, nOptStartIndex ) sRes = table.implode ( tStringsToImplode, sDelimiter ) table.insert ( tTable, vValue ) tTable = table.newInstance ( v0, v1, v2, ... ) table.pushAt ( tTable, nIndex, vValue ) table.sort ( tTable, bOptSortStringNumbersLikeNumbers ) --user nRatio = user.getViewportRatio ( hUser ) --xml nCount, tIndexes = xml.getElementChildCountWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 ) hChild = xml.getElementFirstChildWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 ) hChild = xml.getElementNextSiblingWithNameAndAttributes ( hXMLElement, sOptElementName, sOptAttributeName0, sOptAttributeValue0, sOptAttributeName1, sOptAttributeValue1, sOptAttributeName2, sOptAttributeValue2 )
JPExtendedAPI est un pack très sympa. Sa particularité est qu'il ne crée pas de nouvelle API, mais qu'il améliore les API existantes en y ajoutant des nouvelles fonctionnalités qui sont très utiles lors de la création d'un jeu.
Un exemple très parlant est la possibilité de savoir à tout moment si une touche du clavier est enfoncée ou non. Cette fonctionnalité parait pourtant élémentaire, mais n'est pas présente dans les API proposées par ShiVa, et par conséquent il était nécessaire de tracker soit-même les évènements pour chacune des touches du clavier qui nous intéressait et de stocker son état à l'aide d'une variable booléenne, ce qui est en bref très fastidieux. C'est là qu'intervient JPExtendedAPI qui ajoute la fonction input.isKeyboardKeyDown ( kKeyCode ) qui peut être appelée de n'importe où dans le code, sans avoir à gérer soit-même les évènements clavier.
Ci-dessous quelques fonctions proposées par JPExtendedAPI :
hashtable.push ( htHashtable, sKey, vValue ) hud.setContainerRotation ( hComponent, nRotation ) hud.sizeComponentToFitText ( hComponent ) sRes = table.implode ( tStringsToImplode, sDelimiter ) table.sort ( tTable, bOptSortStringNumbersLikeNumbers )
Ces fonctions ne représentent qu'une petite partie des fonctions proposées par JPExtendedAPI, pour les retrouver toutes, rendez-vous dans la page d'API en suivant le lien ci-dessous.