inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on May 28, 2020 18:40:12 GMT -8
On 1 of my forums, we run an MRPG (Marvel RP Game) where Karma is earned. Karma is, from a perspective, synonymous to XP (eXperience Points) in AD&D. At the end of the game night, the Judge (GM) gives out Karma awards. I'm trying to find a way to make a plugin where my members can click a button to bring up (popup?) a "Karma Calculator". They would need to enter 3 numbers: Current Rank; Desired Rank; # of Column Shifts. From that, the plugin can give them the Karma cost for purchasing/upgrading powers/talents/etc.
The current code I use to plug in into the console to do this for them is:
var a = 14; // Change to CURRENT RANK NUMBER var b = 40; // Change to DESIRED RANK NUMBER var c = 3; // Change to reflect the number of columns shifted var d = 0; // LEAVE AT ZERO - this is an initialization for our total Karma needed
/* Do NOT change anything below this line except where stated below */
for (i = a; i < b; i++) { d += i * 10; } d += c * 200;
How would I go about setting this up to where I could have a popup with 3 fields (by clicking a button) where the member can input the 3 numbers (variables 'a', 'b' and 'c' in the code) and have it output the result on the popup (after clicking the "Calculate" button). The popup would need 2 buttons on the bottom right: "Calculate" and "Close".
Thanks!
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on May 29, 2020 6:26:56 GMT -8
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on May 29, 2020 13:09:39 GMT -8
Peter, THANK YOU very much! Heh, looks like I was trying to make it harder than what it was. I'll be sure to go over the code this weekend and let you know if there's something I don't understand. Thanks again! P.S. That actually solves some problems I was trying to figure out for a quiz plugin I was working on - so this is doubly helpful.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on May 30, 2020 16:19:09 GMT -8
Hey, Peter! Got a question for you. How can I check if a checkbox is checked? In the code, I added this to the HTML: function create_dialog(){ let html = "<div>"; html += "Current Rank Number: <input type='text' id='current-rank' /><br />"; html += "Desired Rank Number: <input type='text' id='desired-rank' /><br />"; html += "# of Columns Shifted: <input type='text' id='cols' /><br />"; html += "<input type='checkbox' id='karma-dbl' name='karma-dbl />"; html += "<label for='karma-dbl'>Check box if a double power</label><br /><br />"; html += "<div id='karma-calculation'></div>"; html += "</div>"; return html; }
but I can't figure out how to test whether the checkbox is checked or not. For this part: for(let i = a; i < b; i ++){ d += i * 10; }
I need it as is for unchecked, but it has to change to d += i * 20; if it is checked. Please help. Thanks! Note: I did take a look at MDN, but really couldn't find a satisfactory answer (they used a <form> and <input type="submit"> in their example).
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jun 1, 2020 3:07:35 GMT -8
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Jun 1, 2020 9:13:29 GMT -8
Thank you very much again, Peter!
|
|