Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Template manager

Trying to get a script to work. The original author is Randy T. The error: "ERROR: You cannot set the imgsrc or avatar of an object unless you use an image that is in your Roll20 Library. See the API documentation for more info." /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'get' of undefined at evalmachine.<anonymous>:4408:35 at eval ( I am guessing it has to do with the name of teh image vs teh token name The script // Template manager {{{ // Implements the commands: // !t // !template // - Allows a player to summon a template token, they must exist somewhere // obviously. // - The token gets placed on the first selected token, if any, or in the // top right of the map. on("chat:message", function(msg) { if(msg.type != "api") return; msg = _.clone(msg); var sender = msg.who.split(" ")[0]; if(msg.content == "!t" || msg.content == "!template") { sendChat("Template Spawner", "/w " + sender + " Usage:<br/>!t [15|30|60] cone<br/>!t [5|10|15|20|30|40] burst"); return; } if(msg.content.startsWith("!t ") || msg.content.startsWith("!template ")) { // Get master template tokens. var cone_15 = findObjs({ _type: "graphic", name: "cone_15_template_master", })[0]; var cone_15_ortho = findObjs({ _type: "graphic", name: "cone_15_ortho_template_master", })[0]; var cone_30 = findObjs({ _type: "graphic", name: "cone_30_template_master", })[0]; var cone_30_ortho = findObjs({ _type: "graphic", name: "cone_30_ortho_template_master", })[0]; var cone_60 = findObjs({ _type: "graphic", name: "cone_60_template_master", })[0]; var cone_60_ortho = findObjs({ _type: "graphic", name: "cone_60_ortho_template_master", })[0]; var burst_5 = findObjs({ _type: "graphic", name: "burst_5_template_master", })[0]; var burst_10 = findObjs({ _type: "graphic", name: "burst_10_template_master", })[0]; var burst_15 = findObjs({ _type: "graphic", name: "burst_15_template_master", })[0]; var burst_20 = findObjs({ _type: "graphic", name: "burst_20_template_master", })[0]; var burst_30 = findObjs({ _type: "graphic", name: "burst_30_template_master", })[0]; var burst_40 = findObjs({ _type: "graphic", name: "burst_40_template_master", })[0]; // Check if all are found... //log(cone_15); //log(cone_15_ortho); //log(cone_30); //log(cone_30_ortho); //log(cone_60); //log(cone_60_ortho); //log(burst_5); //log(burst_10); //log(burst_15); //log(burst_20); //log(burst_30); //log(burst_40); var x = 280; var y = 280; var selected = msg.selected || ""; if(selected.length != 0 && selected[0]._type == "graphic") { var obj = getObj(selected[0]._type, selected[0]._id); x = obj.get("left"); y = obj.get("top"); } var created1 = ""; var created2 = ""; //parse input string, cone or burst? if(msg.content.indexOf("cone") !== -1) { // 15, 30 or 60? if(msg.content.indexOf("15") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 15ft. cones."); created1 = createObj("graphic", { name: "Template: 15ft ortho cone", subtype: "token", imgsrc: cone_15_ortho.get("imgsrc"), width: cone_15_ortho.get("width"), height: cone_15_ortho.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_15_ortho.get("controlledby"), pageid: Campaign().get("playerpageid"), }); created2 = createObj("graphic", { name: "Template: 15ft cone", subtype: "token", imgsrc: cone_15.get("imgsrc"), width: cone_15.get("width"), height: cone_15.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_15.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf("30") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 30ft. cones."); created1 = createObj("graphic", { name: "Template: 30ft ortho cone", subtype: "token", imgsrc: cone_30_ortho.get("imgsrc"), width: cone_30_ortho.get("width"), height: cone_30_ortho.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_30_ortho.get("controlledby"), pageid: Campaign().get("playerpageid"), }); created2 = createObj("graphic", { name: "Template: 30ft cone", subtype: "token", imgsrc: cone_30.get("imgsrc"), width: cone_30.get("width"), height: cone_30.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_30.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf("60") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 60ft. cones."); created1 = createObj("graphic", { name: "Template: 60ft ortho cone", subtype: "token", imgsrc: cone_60_ortho.get("imgsrc"), width: cone_60_ortho.get("width"), height: cone_60_ortho.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_60_ortho.get("controlledby"), pageid: Campaign().get("playerpageid"), }); created2 = createObj("graphic", { name: "Template: 60ft cone", subtype: "token", imgsrc: cone_60.get("imgsrc"), width: cone_60.get("width"), height: cone_60.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: cone_60.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else { sendChat("Template Spawner", "/w " + sender + " No cone available in that size."); } } else if(msg.content.indexOf("burst") !== -1) { // 5, 10 or 20? if(msg.content.indexOf(" 5") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 5ft. burst."); created1 = createObj("graphic", { name: "Template: 5ft burst", subtype: "token", imgsrc: burst_5.get("imgsrc"), width: burst_5.get("width"), height: burst_5.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_5.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf(" 10") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 10ft. burst."); created1 = createObj("graphic", { name: "Template: 10ft burst", subtype: "token", imgsrc: burst_10.get("imgsrc"), width: burst_10.get("width"), height: burst_10.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_10.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf(" 15") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 15ft. burst."); created1 = createObj("graphic", { name: "Template: 15ft burst", subtype: "token", imgsrc: burst_15.get("imgsrc"), width: burst_15.get("width"), height: burst_15.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_15.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf("20") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 20ft. burst."); created1 = createObj("graphic", { name: "Template: 20ft burst", subtype: "token", imgsrc: burst_20.get("imgsrc"), width: burst_20.get("width"), height: burst_20.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_20.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf("30") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 30ft. burst."); created1 = createObj("graphic", { name: "Template: 30ft burst", subtype: "token", imgsrc: burst_30.get("imgsrc"), width: burst_30.get("width"), height: burst_30.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_30.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else if(msg.content.indexOf("40") !== -1) { sendChat("Template Spawner", "/w " + sender + " Spawning 40ft. burst."); created1 = createObj("graphic", { name: "Template: 40ft burst", subtype: "token", imgsrc: burst_40.get("imgsrc"), width: burst_40.get("width"), height: burst_40.get("height"), left: x, top: y, showname: true, showplayers_name: true, layer: "objects", controlledby: burst_40.get("controlledby"), pageid: Campaign().get("playerpageid"), }); } else { sendChat("Template Spawner", "/w " + sender + " No burst available in that size."); } } else { sendChat("Template Spawner", "/w " + sender + " Usage:<br/>!t [15|30|60] cone<br/>!t [5"+ "|10|15|20|30|40] burst"); } var outstring = ""; if(created1 != "") { outstring += created1.get("_id") + " "; } if(created2 != "") { outstring += created2.get("_id"); } if(outstring != "") { sendChat("Template Spawner", "/w " + sender + " Click [here](!del " + outstring + ") to delete templates."); } } }); // }}}
1431281102
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Did the orginal post have images with it?
1431281879
Lithl
Pro
Sheet Author
API Scripter
The script is expecting you to have template graphics with specific names already on the table somewhere. Additionally, the images for those templates need to come from a Roll20 library, not from just searching the web.
Here is the post I found it in Unknown sources
Brian said: The script is expecting you to have template graphics with specific names already on the table somewhere. Additionally, the images for those templates need to come from a Roll20 library, not from just searching the web. Am I understanding correctly? I need to acquire the images on my own PC. Then add them to my Library before I can use them? The part I am confused about is the naming when I add it to my library. Is it the same name as the name the token will be? Or can I add one image to my library then add it as a token 3 times each with a different name (based on the names in the script)?
1431284774

Edited 1431284839
The Aaron
Pro
API Scripter
1) Download the images to your local computer. 2) Make a new page (name doesn't matter, try "templates") 3) Drag all your template images onto that page. 4) Name each one after the template it represents (like 'cone_15_template_master', or 'cone_30_template_master') The script will find the objects with those names to use as the basis for it's spell templates. They must be in a user library because the API is not currently capable of creating images that are in the MarketPlace. Edit : If you need to use this on multiple campaigns, just use the Transmographier to copy that page to the other campaign(s).
The Aaron said: 1) Download the images to your local computer. 2) Make a new page (name doesn't matter, try "templates") 3) Drag all your template images onto that page. 4) Name each one after the template it represents (like 'cone_15_template_master', or 'cone_30_template_master') The script will find the objects with those names to use as the basis for it's spell templates. They must be in a user library because the API is not currently capable of creating images that are in the MarketPlace. Edit : If you need to use this on multiple campaigns, just use the Transmographier to copy that page to the other campaign(s). Thank you
is there a way to find what in teh code is causing an error? /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Object # has no method 'CheckInstall' at Sandbox. (evalmachine. :7083:8) at eval (
1431296004
The Aaron
Pro
API Scripter
hmmm.. process of elimination maybe... If you want to PM me an invite and GM me, I'd be happy to come take a look.
The Aaron said: hmmm.. process of elimination maybe... If you want to PM me an invite and GM me, I'd be happy to come take a look. you still have access from teh last time you helped me up. :)
1431323948
The Aaron
Pro
API Scripter
You wouldn't believe how many campaigns I'm currently joined into... =D Ok. It won't crash anymore but the problem is, you have to upload the images from your library, not from the marketplace library. You need to download each of the images you're going to use, then drag them from your computer back into the game, replacing the ones you have there now. The API cannot create images that are stored in the Marketplace (currently), so it is failing to create the objects, then various dependent code is crashing. I fixed all the dependent code so it won't crash, but you'll still need to take are of the user library issue if you want it to work.
Your profile says 18 :) games as GM I am having a hard time managing one. Thank you for taking the time.
1431390579
Lithl
Pro
Sheet Author
API Scripter
Robert N. said: Your profile says 18 :) games as GM I am having a hard time managing one. Don't let the profile page fool you. It counts games that don't even have players. =P
1431390583
The Aaron
Pro
API Scripter
Those are just the ones I'VE created. =D I'm joined in 44 more.. =D And that's just prod... busy busy.. =D