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

Need help accessing the value of a selection of a Targeted entity.

Hello there, Finally convinced myself to post this here, as normally i shy away from posting stuff in forums. So heres the Brief situation: For a bunch of friends i am currently working on a custom character sheet for a Pokémon style Pen and Paper and now that general Layout is done, it's time for the logic. I did not have experience with javascript before, but i didnt find it that complicated. What confused me though was the Roll20 functions and especially the error Messages. Like, i didnt find any information on what  SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "W" found. Is even supposed to meen. I was able to narrow it down to a part of a  startRoll()  function where i tried to access the value of a different character sheets Select Value with    {{TargetTyp1=[[@{target|Typ1}]]}}  . Funnily enough i already figured out how to get a Number from an input with  {{FLU=[[@{target|GesamtFLU}]]}}  And that just works. So i tried to pull a little workaround by loading the value of the selection into a hidden input on change of teh selected:  on ( 'change:Typ1 change:Typ2' , function (){         getAttrs ([ "Typ1" , "Typ2" ], function ( values ){             let T1 = values . Typ1 ;             let T2 = values . Typ2 ;             console . log ( "Typ1:" , T1 );             console . log ( "Typ2:" , T2 );             setAttrs ({                 "TargetedTyp1" : T1 ,                 "TargetedTyp2" : T2             });         })     }) This works finde, but the hidden input is not accessable like the other attribute. The full function where the Error is within is the following:  on ( 'clicked:ATTACK4' , ( info ) => {         getAttrs ([ 'character_name' , 'ATT4ACC' , 'GesamtACC' , 'ATT4Ttyp' , 'ATT4name' , 'ATT4Staerke' , 'ATT4KAT' , 'CritUp4' , 'LVL' , 'GesamtATK' , 'GesamtDEF' , 'GesamtSPATK' , 'GesamtSPDEF' , 'Typ1' , 'Typ2' , 'Statuseffekt' ], ( values ) => {             console . log ( values );             let name = values . character_name ;             //Wichtig für Genauigkeit             let ATTACC = parseInt ( values . ATT4ACC ) || 100 ;             let ACC = parseInt ( values . GesamtACC ) || 100 ;             //Wichtig für Schaden             let AttackenName = values . ATT4name || "Attacke" ;             let AttackenTyp = values . ATT4Ttyp || "Normal" ;             let AttackenKategorie = values . ATT4KAT || "Status" ;             let CritUp = values . CritUp4 || false ;             let AttStaerke = parseInt ( values . ATT4Staerke ) || 0 ;             let Level = parseInt ( values . LVL ) || 1 ;             let Angriff = parseInt ( values . GesamtATK ) || 1 ;             let Verteidigung = parseInt ( values . GesamtDEF )|| 1 ;             let SPAngriff = parseInt ( values . GesamtSPATK ) || 1 ;             let SPVerteidigung = parseInt ( values . GesamtSPDEF )|| 1 ;             let EigenTyp1 = values . Typ1 || "" ;             let EigenTyp2 = values . Typ2 || "" ;             let Effekt = values . Statuseffekt || "" ;             startRoll ( `&{template:Genauigkeit} {{name= ${ name } }} {{Treffer=[[1d100]]}} {{Z=[[1d15]]}} {{CritRoll=[[1d10000]]}} {{FLU=[[@{target|GesamtFLU}]]}} {{TargetTyp1=[[@{target|Typ1}]]}} {{TargetTyp2=[[@{target|Typ2}]]}} {{Targetname=@{target|character_name}}}` ,             ( results ) => {                 console . log ( "Results:" , results ); // Debugging: Ergebnisse anzeigen                 //wichtig für Genauigkeit                 let HIT = results . results . Treffer . result ;                 let FLU = results . results . FLU . result || 100 ;                 let EnemyTyp1 = results . results . TargetTyp1 . result || "" ;                 let EnemyTyp2 = results . results . TargetTyp2 . result || "" ;                 let ZRoll = results . results . Z || 101 ;                 let CritErgebnis = results . results . CritRoll || 111111111 ;                     const rechnung = Math . floor ( ATTACC * (( FLU - ACC ) / 100 ));                 console . log ( "Rechnung: (AttACC" , ATTACC , "* ((FLU" , FLU , "- ACC " , ACC , ")/100)) =" , rechnung , "Ist höher als " , HIT ); // Debugging: Berechneten Wert anzeigen                     if ( rechnung > HIT ){                     let getroffen = true ;                     console . log ( "Getroffen" );                 }                 else {                     let getroffen = false ;                     console . log ( "Missed" );                 }                 console . log ( CritUp );                 if ( CritUp ){                     if ( CritErgebnis < 1250 ){                         console . log ( CritErgebnis , "Ist kleiner als 1250" );                         Crit = 2 ;                     }                     else { Crit = 1 ;                         console . log ( CritErgebnis , "Ist größer als 1250" );}                 }                 else {                     if ( CritErgebnis < 416 ){                         console . log ( CritErgebnis , "Ist kleiner als 416" );                         Crit = 2 ;                     }                     else {                         console . log ( CritErgebnis , "Ist größer als 416" );                         Crit = 1 ;}                 }                 let damage = BerechneSchaden ( Angriff , SPAngriff , Verteidigung , SPVerteidigung , AttackenTyp , EigenTyp1 , EigenTyp2 , AttackenKategorie , Effekt , AttStaerke , Level , EnemyTyp1 , EnemyTyp2 , ZRoll , Crit );                 console . log ( "Damage=" , damage )                 finishRoll (                     results . rollId ,                     {                         getroffen:getroffen ,                     }                 );             });         });     }); I hope the German attribute names don't make it too hard for you to understand what's what, but i hope one of you might know the solution to that Problem.  Thanks for reading through this, time is valuable and you spending time on my issue is higly appreciated
1721574438

Edited 1721575139
GiGs
Pro
Sheet Author
API Scripter
When you get an error like SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "W" found. that's not a javascript error, that tells you somerthing is wrong with your roll in Roll20. That's a roll20 dice roll error. (PS: I find those error messages useless, too. They are good for telling that there is an error, but not for figuring out what the error is.) The best way to handle this is to extract your roll, put it in an Ability, then experiment with it till you get it working properly. Then you can put it back inside startRoll. So you have this roll &{template:Genauigkeit} {{name=${name}}} {{Treffer=[[1d100]]}} {{Z=[[1d15]]}} {{CritRoll=[[1d10000]]}} {{FLU=[[@{target|GesamtFLU}]]}} {{TargetTyp1=[[@{target|Typ1}]]}} {{TargetTyp2=[[@{target|Typ2}]]}} {{Targetname=@{target|character_name}}} Play with that as an Ability, and figure out why it is failing. Change any reference like ${name} which are for your javascript, just put anything in there as a replacment, like {{name=Bilbo}}. The important thing is finding the error and fixing it. For the record, it looks right to me, so you'd probably need to look at the character sit is usually used against and find the values of all thoese target attributes. The error could also be in your rolltemplate, which processes the roll. So that might need to be posted too. At the very least, change the template to default while testing it, like &{template:default}
1721574851
GiGs
Pro
Sheet Author
API Scripter
Another thing you can do, if working in javascript, is to remove most of the function, and gradually build it back up to see when the error happens.