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

api help

total noob looking for help barValues = parseInt(a.get("bar1_value"))+parseInt(b.get("bar2_value")); var pilotGun = GetAttribute(wrds[2],"Pilotgunnery"); pilotGun = parseInt(pilotGun); if(isNaN(pilotGun))pilotGun = 4; var l = MakeCheck(charIds[wrds[2]],w,d,pilotGun+barValues,arc); var pilotGun = GetAttribute(wrds[2],"Pilotgunnery");   if i read this right is pulling the number from the Pilotgunnery attribute on the character sheet pilotGun = parseInt(pilotGun); this is what it got from pilotgunnery into a integer  if(isNaN(pilotGun))pilotGun = 4; this has been setting the var back to 4 what is it suppose to be doing i think it is suppose to set pilotgun to 4 if pilot gun is a nul field??? what its suppose to do is get the pilot gunnery value and add it to the 2 bar values its always reading as 4 no matter what pilotgunnery attribute is.  HELP!
1519409929

Edited 1519410396
this is the entire section if needed case "c" : if(wrds.length!=5)return; var a = GetToken(charIds[wrds[2]]); var b = GetToken(charIds[wrds[3]]); var nm = wrds[4].split(' '); nm = nm[0]; if(a==undefined||b==undefined||nm==undefined) { sendChat("","/em You done fucked up bro.") return; } var w = GetWeapons(charIds[wrds[2]]); var d = Dis(a,b); var arc = Arc(a,b); barValues = parseInt(a.get("bar1_value"))+parseInt(b.get("bar2_value")); var pilotGun = GetAttribute(wrds[2],"Pilotgunnery"); pilotGun = parseInt(pilotGun); if(isNaN(pilotGun))pilotGun = 4; var l = MakeCheck(charIds[wrds[2]],w,d,pilotGun+barValues,arc); sendChat(nm,"/em Weapon Check"); sendChat(nm,arc); if(l.length>0) { for(var i = 0;i<l.length;i++)sendChat("("+l[i][2]+") "+l[i][0],l[i][1].toString()); log("","/em You done fucked up bro.", w , d , arc) } else { sendChat("","No Possible Weapons"); log("","/em You done fucked up bro.", w , d , arc) } break; is this section right? function getAtt(array,str) { for(var i = 0;i<array.length;i++) { if(array[i][0]==str) { return array[i][1]; } } return null; }
1519421896
GiGs
Pro
Sheet Author
API Scripter
Posts like this are easier to read if you use the code block formatting (see the bar at the top of the post as you are writing it, the mark at the far left, next to B, has the formatting options). is PilotGunnery a number?  this line grabs my attention: var pilotGun = GetAttribute(wrds[2],"Pilotgunnery");   Do you have a GetAttribute function you haven't shared? Knowing what that function contains is probably very important to figuring out what's going on here.