Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checker if audio is loaded to prevent desyncing #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions eventsFunctionsExtensions/audiocheckerfunctions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"author": "",
"category": "",
"extensionNamespace": "",
"fullName": "Sound Checker",
"helpPath": "",
"iconUrl": "",
"name": "AudioCheckerFunctions",
"previewIconUrl": "",
"shortDescription": "",
"version": "",
"description": "",
"tags": [],
"authorIds": [],
"dependencies": [],
"eventsFunctions": [
{
"description": "Check if sound is preloaded",
"fullName": "Check if sound is preloaded",
"functionType": "Condition",
"group": "Audio",
"name": "CheckIfSoundIsPreloaded",
"sentence": "Check if sound _PARAM1_ is preloaded",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [],
"actions": []
},
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": "const SoundManager = runtimeScene.getSoundManager();\nconst FullPath = eventsFunctionContext.getArgument(\"Filename\");\nconst FileName = SoundManager._availableResources[FullPath].file;\n\neventsFunctionContext.returnValue = false;\n\nif(SoundManager._loadedSounds[FileName] != undefined) {\n eventsFunctionContext.returnValue = SoundManager._loadedSounds[FileName].state() == \"loaded\";\n}",
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
}
],
"parameters": [
{
"description": "Filename",
"name": "Filename",
"type": "soundfile"
}
],
"objectGroups": []
}
],
"eventsBasedBehaviors": [],
"eventsBasedObjects": []
}
24 changes: 12 additions & 12 deletions eventsFunctionsExtensions/jsonloaderforfnf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
"dependencies": [],
"eventsFunctions": [
{
"description": "Load FNF json filename ",
"fullName": "Load FNF json filename ",
"description": "Loads a JSON resource into a scene structure variable.",
"fullName": "Load a JSON resource in a scene variable",
"functionType": "Action",
"name": "LoadJSONFile",
"sentence": "Load FNF json filename _PARAM1_ to scene structure variable _PARAM2_",
"name": "LoadJSONToScene",
"sentence": "Load _PARAM1_ into scene variable _PARAM2_",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": "\nasync function fetchJSON(file) {\n const response = await fetch('./'+file);\n const data = await response.json();\n return data;\n}\n\n(async () => {\n const charting = await fetchJSON(eventsFunctionContext.getArgument(\"FileName\"));\n console.log({charting});\n runtimeScene.getVariables().get(eventsFunctionContext.getArgument(\"SceneVariable\")).fromJSObject(charting);\n})();\n",
"inlineCode": "eventsFunctionContext\n .getArgument(\"Variable\")\n .fromJSObject(\n runtimeScene\n .getGame()\n .getJsonManager()\n .getLoadedJson(eventsFunctionContext.getArgument(\"Resource\"))\n );\n",
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
"eventsSheetExpanded": true
}
],
"parameters": [
{
"description": "FileName",
"name": "FileName",
"type": "string"
"description": "The resource to load the JSON from",
"name": "Resource",
"type": "jsonResource"
},
{
"description": "SceneVariable",
"name": "SceneVariable",
"type": "string"
"description": "The scene variable to load the JSON to",
"name": "Variable",
"type": "scenevar"
}
],
"objectGroups": []
Expand Down
Loading