From 0d11be948804545849113e2c3f212dec7fc01458 Mon Sep 17 00:00:00 2001 From: Patterntrick Date: Thu, 23 Mar 2017 06:15:53 -0700 Subject: [PATCH] Add files via upload --- pUtils.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pUtils.js diff --git a/pUtils.js b/pUtils.js new file mode 100644 index 0000000000..e3ed41fa8f --- /dev/null +++ b/pUtils.js @@ -0,0 +1,24 @@ +getEntityTextures = function(id) { + var results = null; + var properties = Entities.getEntityProperties(id, "textures"); + if (properties.textures) { + try { + results = JSON.parse(properties.textures); + } catch(err) { + logDebug(err); + logDebug(properties.textures); + } + } + return results ? results : {}; +} + +setEntityTextures = function(id, textureList) { + var json = JSON.stringify(textureList); + Entities.editEntity(id, {textures: json}); +} + +editEntityTextures = function(id, textureName, textureURL) { + var textureList = getEntityTextures(id); + textureList[textureName] = textureURL; + setEntityTextures(id, textureList); +} \ No newline at end of file