View unanswered posts | View active topics It is currently 18 Jul 2018 22:07

Forum rules


- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.



Reply to topic  [ 29 posts ]  Go to page Previous  1, 2, 3  Next
Math 
Author Message
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
Okay, took a bit for an amateur, but here's what I got.
My idea is, alias or trigger, input in coppers. Like, <estimate 3500>
How's this look?
Code:
var copp = regexp
var min = 12;
var silv = Math.floor(copp/min);
var srem = Math.floor(%copp/min);
var copp = Math.floor(copp+srem);
var gold = Math.floor(silv/min);
var grem = min%silv;
var silv = Math.floor(silv+grem);
var plat = Math.floor(gold/min);
var prem = min%gold;
var gold = Math.floor(gold+prem);
gwc.output.append(plat + " plats.");
gwc.output.append(gold + " gold.");
gwc.output.append(silv + " silvers.");
gwc.output.append(copp + " coppers.");

Would be cooler, if I could get it to do exactly what the bank does, i.e. estimate 30(c), 27(s), 90(g), 200 to come out with a full minimize. So it's easier to know exactly how much money you have.

_________________
Alea iacta est. Serius regredi est.


Last edited by Kwevin on 26 May 2017 08:47, edited 1 time in total.



26 May 2017 07:50
Profile
Rising Hero
User avatar

Joined: 29 Feb 2016 19:51
Posts: 318
Location: Everywhere
Kwevin wrote:
Okay, took a bit for an amateur, but here's what I got.
Code:
var x = 60; //The regexp number to input. Kinda like an alias.
var y = 12; //Division number.
var num = Math.floor(x/y); //Coppers reduced.
gwc.output.append(num + " silvers.");
var rem = Math.floor(y%x); //Help? Wouldn't work right!
gwc.output.append
Hmm. So that last bit.. Looks unfinished..?
Also, why are you using the percent sign to calculate "rem" ?
I'm assuming "rem" is the variable for the "remainder"
In which case, you'd want:
Code:
var rem = (x - (num * 12)) //JS automatically executes math equations, right?
Assuming that "x" is the original amount of coppers, yes?
I'm not the greatest at making code fly within the game..
I'm much better at using JS inside HTML..
But you should be able to get this to work.
The way it is now, you should be able to output how many Silver coins your Coppers are worth with the number of Coppers left over.
To pump it up to Plats, you'll need a few more equations.

_________________
Chillin
[-_- ]
Click here to become a pupil of my Brute! It's really cool, I swear.


26 May 2017 08:18
Profile WWW
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
Thing is, I've got a really solid skeleton of what I want. The only thing that is stopping me is how to take the regexp number, and use that as a variable.
The % seems to work.
Code:
var copp =
var min = 12;
//Division rate^
var silv = Math.floor(copp/min);
//silvers computed
//x - num * 12
var srem = copp - (silv * min);
//remainder of coppers
var copp = srem;
//remainder of copper not into silver is now coppers
var gold = Math.floor(silv/min);
// golds computed
var grem = silv  - (gold * min);
//remainder of silvers from the gold
var silv = Math.floor(silv+grem);
//adding remainder of silvers to the gold
var plat = Math.floor(gold/min);
//gold converted to plat
var prem = gold - (plat * min);
//remainder of golds
var gold = Math.floor(gold+prem);
//adding total golds
gwc.output.append(plat + " plats.");
gwc.output.append(gold + " gold.");
gwc.output.append(silv + " silvers.");
gwc.output.append(copp + " coppers.");
//display

My apologies, Melarec. I did that portion at 2 this morning, and my copy paste was sloppy. Above is my code in full.

_________________
Alea iacta est. Serius regredi est.


Last edited by Kwevin on 26 May 2017 16:00, edited 3 times in total.



26 May 2017 15:27
Profile
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
Update: Implemented my chunk. It works just like a shop!

7500 coppers is:
4 plats.
64 gold.
637 silvers.
0 coppers.
Aaaannnnd... 637 silver is something like 7600 copper.

_________________
Alea iacta est. Serius regredi est.


26 May 2017 15:36
Profile
Myth
User avatar

Joined: 09 Mar 2010 20:33
Posts: 1331
Location: UK
Good job.

Now add some nice colors...

Eg
Code:
gwc.output.append("Your coloured text");
gwc.output.color("#0059B3");



Can get the hex colour codes from google
Attachment:
download9eef3d6f_f0_2fPictures_2fScreenshots_2fScreenshot_2017-05-26-15-17-45.png
download9eef3d6f_f0_2fPictures_2fScreenshots_2fScreenshot_2017-05-26-15-17-45.png [ 59.72 KiB | Viewed 1257 times ]

_________________
http://genesisquests.pbworks.com/
Join up and help each other with Quests :)


26 May 2017 16:22
Profile
Site Admin
User avatar

Joined: 03 Mar 2010 20:51
Posts: 2150
Location: Some old coffin
Sounds like you're having fun. :-)

G.

_________________
Mmmmmm ... pie ...


26 May 2017 17:15
Profile
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
I am! But I need help! I wanna make this a trigger. Here's my plan.

Alias: something simple, like an output append, which triggers the trigger.

Trigger, regexp is input, instead of my specific copper count. That was test. Help with the regexp portion?
It's not done yet, by any means. But, yes, colors.

And it is horribly inaccurate.

_________________
Alea iacta est. Serius regredi est.


Last edited by Kwevin on 26 May 2017 18:23, edited 1 time in total.



26 May 2017 18:12
Profile
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
Tarax the Terrible wrote:

Can get the hex colour codes from google
Attachment:
download9eef3d6f_f0_2fPictures_2fScreenshots_2fScreenshot_2017-05-26-15-17-45.png


So far, my favorite hex color supplier is http://htmlcolorcodes.com/color-names/

_________________
Alea iacta est. Serius regredi est.


26 May 2017 18:18
Profile
Rising Hero
User avatar

Joined: 29 Feb 2016 19:51
Posts: 318
Location: Everywhere
Kwevin wrote:
Update: Implemented my chunk. It works just like a shop!
7500 coppers is:
4 plats.
64 gold.
637 silvers.
0 coppers.
Aaaannnnd... 637 silver is something like 7600 copper.
Looks like you might have some recursive addition going on..
When you calculate the remainder from the next tier, it's adding that to the previous count.
So you end up with coins out of nowhere.
You should be an accountant; making money from nothing is their specialty!

If you're looking for a total, then you need to work backwards.
Calculate Plats first. Then use the remainder to calculate Gold. Then use that remainder to calculate Silver. Then the last remainder is your Copper.
What you have above is:
7500 coppers is 4 Plats. (Plus a bit, so the remainder re-adds to the Gold pile)
7500 coppers is 52 Gold. (You rounded down, so you ended up with an extra 12 from the remainder calculation.)
7500 coppers is 625 Silver. (Same as above.)
If that's what you want, excellent, just toss out the remainders.
Or, you can keep the remainders, just calculate every one of them separately and keep them in-line with the base calculation.
You would end up with something similar as below:
Code:
gwc.output.append(copp + "Copper Coins is" + c2pPlats + "Platinum Coins," + c2pGold + "Gold Coins," + c2pSilv + "Silver Coins, and" + c2pCopp + "Copper Coins.");
gwc.output.append(copp + "Copper Coins is"  + c2gGold + "Gold Coins," + c2gSilv + "Silver Coins, and" + c2gCopp + "Copper Coins.");
gwc.output.append(copp + "Copper Coins is"  + c2sSilv + "Silver Coins, and" + c2sCopp + "Copper Coins.");
And you'd need to calculate all of them separately. Hence the "c2(p|g|s)" variables.
And the remainder should never be 12 or more. So, the most you could get is "x Plats, 11 Gold, 11 Silver, and 11 Copper"
You could also add a dozen "if" statements to see if each remainder is above zero and adjust the output accordingly.
You're on the right track, though!

_________________
Chillin
[-_- ]
Click here to become a pupil of my Brute! It's really cool, I swear.


26 May 2017 18:43
Profile WWW
Veteran

Joined: 21 Mar 2016 09:17
Posts: 206
Do you know of any resource I can use to debug line by line? I'm currently using Droidscript.

_________________
Alea iacta est. Serius regredi est.


27 May 2017 00:33
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 29 posts ]  Go to page Previous  1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.