
Hello, 1st post and 1st time coding, if I did not format this post or the code properly please excuse me. And please advise! I wanted to try and make an API that spawns out token objects that my players can use for AOE. All of the other APIs that I have see or tired are either broken or to difficult to setup or use. When used; the new object will spawn one square below. I have never written code before so I am unsure what I am doing. I am stuck on ReferenceError: spawnFX is not defined and I know the Line type works that was the code I started with before adding the switch(AOEType) for each one. I seems to breaks on the other 3 (CONE, CIRCLE, SQUARE) Please advise //commands
//!AOE [TYPE] [unit Height] [Unit Width]
//TYPE are either LINE, CIRCLE, CONE, SQUARE
//UNITS is number of feet, default is 5 feet
on("ready",function(){
sendChat("AOE API","/w GM ONLINE", null, {noarchive:true})
on("chat:message",function(msg){
if(msg.type=="api" && msg.content.indexOf("!AOE")==0)
{ var args = msg.content.split(" ");
//looks for augment after !AOE for type height and width
var AOEType = args[1]
if(args[1]===undefined)
{
sendChat("AOE API","Type, Height or Width was not entered");
return;
}
//Height - Feet to pixel conversion
var HeightFeet = Number(args[2])*.2
if(args[2]===undefined)
{
HeightFeet=5*.2;
}
var ht=70*HeightFeet
if(isNaN(ht)){
sendChat("AOE API","Please enter a vaild number for Height");
return;
}
//Width - Feet to pixel conversion
var WidthFeet = Number(args[3])*.2
if(args[3]===undefined)
{
WidthFeet=5*.2;
}
var wt=70*WidthFeet
if(isNaN(wt)){
sendChat("AOE API","Please enter a vaild number for Width");
return;
}
//Making sure a character was selected
var selected = msg.selected;
if(selected===undefined)
{
sendChat("AOE API","Please Select a Token");
return;
}
//setting imgscr var by AOE type
var AOEimg
var ChatText
switch(AOEType){
case "Line":
AOEimg = "<a href="https://s3.amazonaws.com/files.d20.io/images/126640672/RsRo9Z1l_eLjsZ6ymnvXDw/thumb.png?158770167055" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/126640672/RsRo9Z1l_eLjsZ6ymnvXDw/thumb.png?158770167055</a>";
ChatText = "is using an AOE Template of a Line " + HeightFeet/.2 +"ft. long by " + WidthFeet/.2 + "ft. wide";
break;
case "Circle":
AOEimg = "<a href="https://s3.amazonaws.com/files.d20.io/images/126640666/njSD_xUkdGPirWLvOiUhTg/thumb.png?15877016695" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/126640666/njSD_xUkdGPirWLvOiUhTg/thumb.png?15877016695</a>";
ChatText = "is using an AOE Template of a Circle or Sphere with at Diameter of "+ WidthFeet/.2 + "ft. wide";
break;
case "Cone":
AOEimg = "<a href="https://s3.amazonaws.com/files.d20.io/images/126640680/WbEAoDFGjh_T6fIDOA9C2w/thumb.png?15877016735" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/126640680/WbEAoDFGjh_T6fIDOA9C2w/thumb.png?15877016735</a>";
ChatText = "is using an AOE Template of a Cone "+ WidthFeet/.2 + "ft. long";
break;
case "Square":
AOEimg = "<a href="https://s3.amazonaws.com/files.d20.io/images/126640653/xEykgzycg3KXenncO2NfOw/thumb.png?15877016675" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/126640653/xEykgzycg3KXenncO2NfOw/thumb.png?15877016675</a>";
ChatText = "is using an AOE Template of a " + HeightFeet/.2 + "ft. Square or Cube";
break;
default:
sendChat("AOE API","Please select Square, Line, Circle, or Cone for AOE Type");
return;
}
var tok = getObj("graphic",selected[0]._id);
var character = getObj("character",tok.get("represents"));
var playerList = character.get("controlledby");
//current math sets location under selected
var objLeft = tok.get("left");
var objTop = tok.get("top")+((ht/2)-(70/2))+70;
createObj("graphic",{
left:objLeft,
top:objTop,
height:ht,
width:wt,
pageid:tok.get("pageid"),
layer:"objects",
imgsrc:AOEimg,
name:tok.get("name") + "'s " + AOEType,
controlledby:playerList
});
sendChat(tok.get("name"),ChatText);
switch(AOEType){
case "Line":
spawnFxBetweenPoints({x:tok.get("left"), y:tok.get("top")},{x:tok.get("left"), y:tok.get("top")+ht}, "beam-holy", tok.get("pageid"));
break;
case "Circle":
spawnFx(objLeft, objTop,"burst-death",tok.get("pageid"));
break;
case "Cone":
spawnFxBetweenPoints({x:tok.get("left"), y:tok.get("top")},{x:tok.get("left"), y:tok.get("top")+ht}, "breath-fire", tok.get("pageid"));
break;
case "Square":
spawnFx(objLeft, objTop,"bomb-water",tok.get("pageid"));
break;
default:
sendChat("AOE API","Please select Square, Line, Circle, or Cone for AOE Type");
return;
}
}
});
});