Weapon selection macro help!


Edited 1507001054
Is it possible to create a macro that prompts you to select the weapon you are attacking with?  Here is what I've got so far.  I want to be able to select a different character and the weapon that PC is using. @{selected|token_name} Swings his Greataxe at @{target|token_name} and rolls a [[1d20+2[Dex]+2[Prof]]] to hit for: [[ 1d12 + 2[Dex] ]] Damage. Crit= +[[1d6]] Damage.
Firstly what sheet are you using? and secondly the best way I can think of off the top of my head is the same as you have there but replace Greataxe with ?{Which Weapon?|Weapon 1,@{selected|repeating_attack_$0_attack}|Weapon 2,@{selected|repeating_attack_$0_attack}|Weapon 3,...} but you would have to know the order of each character's weapons on their sheet.

Edited 1507050732
I'm using the D&D 5th Edition (OGL by Roll20).
Are you set on having this as a line or would you prefer it as a roll template? I believe it would be simpler (and in my opinion looks nicer) if you used a roll template. Are you also set on selecting a PC and a weapon because the only way of doing both is to know the order of the character's weapons in each sheet like I said before? If you had a macro per PC you wouldn't have to know the order of the weapons and could just select the weapons from a dropdown list.
I'm still very new to making a macro or api scripts so I'm very open to any suggestion or criticism that will help me learn.  I'm not set on having this as a line.  It was the only way I found to get it done at all.  I'm also a big fan of simpler and looking nicer.  Can this method be used for monsters or NPCs as well? 
So say you had a PC with 2 weapons Greataxe and Javelin and if you filled in the weapon fully (or dragged and dropped them from the sheet you should see something like this:   Now if you click on either of them it should roll an attack in the chat bar. If you click in the chat box then press the up arrow on your keyboard it will give you the last roll, i.e. the attack you just made. It should look something like this: @{Name|wtype}&{template:atk} {{mod=+5}} {{rname=[Greataxe](~-KvZ8ZgiXozPDvwM5JtC|repeating_attack_-KvZKySr2EsG162WYSxv_attack_dmg)}} {{rnamec=[Greataxe](~-KvZ8ZgiXozPDvwM5JtC|repeating_attack_-KvZKySr2EsG162WYSxv_attack_crit)}} {{r1=[[@{Name|d20}cs>20 + 3[STR] + 2[PROF]]]}} @{Name|rtype}cs>20 + 3[STR] + 2[PROF]]]}} {{range=}} {{desc=}} {{spelllevel=}} @{Name|global_attack_mod} ammo= @{Name|charname_output} Copy and paste this into your new macro but replace every time 3[STR] appears with @{Name|strength_mod}[STR] and 2[PROF] with @{Name|pb}[PROF] and lastly replace {{mod=+5}} with {{mod=@{Name|strength_mod}[STR]+@{Name|pb}[PROF]}} unless you have a weapon that uses dex instead of strength in which case use @{Name|dexterity_mod}[DEX] in both cases instead. Save this macro as greataxe and then do the same for javelin. Finally create another macro and put this: ?{Which Attack?|Greataxe, #greataxe|Javelin, #javelin} Save the macro as whatever you want and whenever you click it it will give you a drop-down menu to pick between Greataxe and Javelin and will roll the attack for which ever one you choose. I hope this all makes sense I'm awful at explaining stuff sometimes.
Just as I started to finish writing that last post I realised there is a way to make a macro that allows you to pick both the PC and their attack but the code is very long and quite messy
In fact ignore all of what I said in the first post, there's a lot easier way of doing it that I completely forgot about. Use the up arrow trick I described before to get specifically this part of the coding: -KvZ8ZgiXozPDvwM5JtC|repeating_attack_-KvZKySr2EsG162WYSxv_attack_dmg The bit of gibberish in the beginning is called a Character ID  and relates to a specific character sheet and the gibberish in the middle is called a Row ID  and relates specifically to the attack you rolled. Both of these bundles of symbols will look different for you as they're specific to every character sheet/attack but they are useful because it will mean this works even if your player changes their character or weapon in any way. Then copy that line into this wording  %{-KvZ8ZgiXozPDvwM5JtC|repeating_attack_-KvZKySr2EsG162WYSxv_attack} Notice how I dropped the _dmg at the end because we just want the attack. Now copy and paste this new Ability  into the macro I wrote before but instead of #greataxe and #javelin you have this: ?{Which Attack?|Greataxe, %{-KvZ8ZgiXozPDvwM5JtC|repeating_attack_-KvZKySr2EsG162WYSxv_attack}|Javelin, %{-KvZ8ZgiXozPDvwM5JtC|repeating_attack_"Gibberish for the javelin"_attack}} Sorry I was so dumb before hopefully I haven't confused you too much with this.
Will this work for NPCs and monsters too?
It should do, the only difference is when you do the up arrow trick they will end in ..._npc_dmg} which you need to replace with ..._npc_action} Let me know if it works for you or if you have any more questions. :)
@{Arpaktikós|wtype}&{template:atkdmg} {{mod=+5}} {{rname=G.Axe}} {{r1=[[@{Arpaktikós|d20}cs>20 + 3[STR] + 2[PROF]]]}} @{Arpaktikós|rtype}cs>20 + 3[STR] + 2[PROF]]]}} {{attack=1}} {{range=10ft}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d12 + 3[STR]]]}} {{dmg1type=Slashing }} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d12[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}} {{spelllevel=}} @{Arpaktikós|global_attack_mod} @{Arpaktikós|global_damage_mod} @{Arpaktikós|global_damage_mod_crit} {{globaldamagetype=@{Arpaktikós|global_damage_type}}} ammo= @{Arpaktikós|charname_output}@{Arpaktikós|wtype}&{template:atkdmg} {{mod=+5}} {{rname=G.Axe}} {{r1=[[@{Arpaktikós|d20}cs>20 + 3[STR] + 2[PROF]]]}} @{Arpaktikós|rtype}cs>20 + 3[STR] + 2[PROF]]]}} {{attack=1}} {{range=10ft}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d12 + 3[STR]]]}} {{dmg1type=Slashing }} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d12[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}} {{spelllevel=}} @{Arpaktikós|global_attack_mod} @{Arpaktikós|global_damage_mod} @{Arpaktikós|global_damage_mod_crit} {{globaldamagetype=@{Arpaktikós|global_damage_type}}} ammo= @{Arpaktikós|charname_output} This is what I got when I rolled his Greataxe attack.  Any idea why the line you said to look for isn't there and why is there are so many lines?
Because you have auto roll damage and crits on. If you turn it off and roll the attack again you should get the line I mentioned before. There's lots of ways to get Character and Row IDs but this way is one of the quickest and probably the easiest to explain through text. And there's so many lines because that's all the properties of the attack and damage rolls of your greataxe. Also I'm pretty sure you pasted it twice :P
I've turned off all that and I still get what I gave you before except I apparently did paste it twice.  Here is the latest one which is just like the others. @{Arpaktikós|wtype}&{template:atkdmg} {{mod=+5}} {{rname=Greataxe}} {{r1=[[@{Arpaktikós|d20}cs>20 + 3[STR] + 2[PROF]]]}} @{Arpaktikós|rtype}cs>20 + 3[STR] + 2[PROF]]]}} {{attack=1}} {{range=10ft}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d12 + 3[STR]]]}} {{dmg1type=Slashing }} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d12[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}} {{spelllevel=}} @{Arpaktikós|global_attack_mod} @{Arpaktikós|global_damage_mod} @{Arpaktikós|global_damage_mod_crit} {{globaldamagetype=@{Arpaktikós|global_damage_type}}} ammo= @{Arpaktikós|charname_output} Is there something else I should have set differently?
I just tried it with a different character and finally got it @{Haraan|wtype}&{template:atk} {{mod=+2}} {{rname=[Mace](~-Kt8bhcAj4JTkWRTZ6sQ|repeating_attack_-KuBPI7f8NsZsnbVaXnw_attack_dmg)}} {{rnamec=[Mace](~-Kt8bhcAj4JTkWRTZ6sQ|repeating_attack_-KuBPI7f8NsZsnbVaXnw_attack_crit)}} {{r1=[[@{Haraan|d20}cs>20 + 2[PROF]]]}} @{Haraan|rtype}cs>20 + 2[PROF]]]}} {{range=}} {{desc=}} {{spelllevel=}} @{Haraan|global_attack_mod} ammo= @{Haraan|charname_output} I don't understand why it works for 1 character but not another.  
So in the settings on the character sheet for the first one the setting for AUTO DAMAGE ROLL is set to Don't Auto Roll Damage? And when you click the attack for that first character is damage rolled in the chat?
To both parts? That obviously contradict each other, hmmm. The only thing I can suggest is closing the character sheet and opening it again and if that doesn't work restarting the tab the game is in. If it's still not fixed after that post a reply here  https://app.roll20.net/forum/post/5576582/5th-edition-ogl-by-roll20-v2-dot-0 saying that the sheet is auto rolling damage when you've set it not to and hopefully a dev can fix the issue soon. If it works for your other sheets I would recommend using the method I showed before to get the Row ID for the weapon. However, for the character it's not working for, for each weapon you will have to right click on the weapon and select "Inspect" and then look for a little bit of code that looks similar to this <div class="repitem" data-reprowid="-KC0zCLum1Rq3V5wssyE"> when you scroll your mouse over this line of the code the row with your weapon should get highlighted. This will confirm it is the Row ID for that weapon and you can get it that way. You can then do this for each weapon in the characters sheet. As for the character ID you can get that through the same method of right click inspect but right click on the 'background' of the sheet, i.e not any of the fields. This should highlight a line that looks like this: <div class="dialog characterdialog ui-dialog-content ui-widget-content" data-characterid="-KleQDHK_lYqPjZB-hj_"...> which is where you get the character ID from. Hope that helps.
Getting real late here so I'll have to try that tomorrow.  Thanks for your help this evening.