Math

Need some help with your MUD client? Forgot your password? Get help here.
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.
User avatar
Melarec
Rising Hero
Posts: 318
Joined: 29 Feb 2016 19:51
Location: Everywhere
Contact:

Re: Math

Post by Melarec » 27 May 2017 01:00

Kwevin wrote:Do you know of any resource I can use to debug line by line? I'm currently using Droidscript.
Nope. I use Notepad. I like making things difficult for myself.
W3 also has a Tryit Editor.. It doesn't tell you what you've done wrong, but it does color the code, making it easier to read.
http://www.w3schools.com/html/tryit.asp ... html_basic

User avatar
Tarax the Terrible
Myth
Posts: 1331
Joined: 09 Mar 2010 20:33
Location: UK

Re: Math

Post by Tarax the Terrible » 27 May 2017 02:02

OK I got a question cus I'm not that familiar with the client.

Is there a way for a trigger to 'fire' an alias.

Code: Select all

Simple example:
Alias: lc = get all from corpse
Trigger: you killed = lc
I know u can set lc as a game alias and trigger output as send lc.
Want a trigger that resolves lc to get all from corpse in the client before sending it to the mud.


Next step.
A trigger where u can send a bunch of aliases and plain commands.

Code: Select all

Simple example:
Alias: lc = get all from corpse
Trigger: you killed 
= 
lc
get imbued items from corpse
http://genesisquests.pbworks.com/
Join up and help each other with Quests :)

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Math

Post by Kwevin » 28 May 2017 06:22

That is possible. Anything is possible with code! :D In all seriousness, I unfortunately can't tell you. I'm not experienced with code.
Alea iacta est. Serius regredi est.

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Math

Post by Kwevin » 28 May 2017 06:30

Code: Select all

var copp = 1728;
if copp >= 1728
   var plat = copp/1728;
   var prem = copp - (plat * 1728);
   var gold = prem/144;
   var grem = prem - (gold * 144);
   var silv = grem/12;
   var srem = grem - (silv * 12);
   var copp = srem
(end);
if copp >= 144
   var plat = 0;
   var gold = copp/144;
   var grem = copp - (gold * 144);
   var silv = grem/12;
   var srem = grem - (silv * 12);
   var copp = srem;
(end);
if copp >= 12
   var plat = 0;
   var gold = 0;
   var silv = copp/12;
   var srem = copp - (silver * 12);
   var copp = srem;
(end);
if copp < 12
   gwc.output.color("#FF1493");
   gwc.output.append("But it already is minimized!");
(end);
gwc.output.color("#98AFC7");
gwc.output.append(plat + " platinum.");
gwc.output.color("gold");
gwc.output.append(gold + " gold.");
gwc.output.color("khaki");
gwc.output.append(silv + " silvers.");
gwc.output.color("#B87333");
gwc.output.append(copp + " coppers.");
It won't work for some reason. Anyone know what's wrong with it?

Two other things.
Firstly, I want the initial "copp" var to be a wildcard from the pattern (if possible, and if trigger) or better, something from the command (if possible, and if alias).

Secondly, the way I have it set up, in if statements, I want it to skip the code that goes plats to coppers if it can't go to plats. Or is that a bunch of redundant code?
Alea iacta est. Serius regredi est.

User avatar
Melarec
Rising Hero
Posts: 318
Joined: 29 Feb 2016 19:51
Location: Everywhere
Contact:

Re: Math

Post by Melarec » 28 May 2017 07:43

Kwevin wrote:

Code: Select all

var copp = 1728;
  if (copp >= 1728) {
    var plat = copp/1728;
    var prem = copp - (plat * 1728);
    var gold = prem/144;
    var grem = prem - (gold * 144);
    var silv = grem/12;
    var srem = grem - (silv * 12);
    var copp = srem
  } else { 
      if (copp >= 144) {
        var plat = 0;
        var gold = copp/144;
        var grem = copp - (gold * 144);
        var silv = grem/12;
        var srem = grem - (silv * 12);
        var copp = srem;
     } else {
         if (copp >= 12) {
           var plat = 0;
           var gold = 0;
           var silv = copp/12;
           var srem = copp - (silver * 12);
           var copp = srem;
        } else {
            if (copp < 12) {
              gwc.output.color("#FF1493");
              gwc.output.append("But it already is minimized!");
            }
           }
      }
   }
gwc.output.color("#98AFC7");
gwc.output.append(plat + " platinum.");
gwc.output.color("gold");
gwc.output.append(gold + " gold.");
gwc.output.color("khaki");
gwc.output.append(silv + " silvers.");
gwc.output.color("#B87333");
gwc.output.append(copp + " coppers.");
The "if, else, if" statements should work now..
If I counted the brackets properly..
I'm not sure how to get "copp" to be defined as an input variable..
You may have to edit the global copp manually then run the code with a designated alias.

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Math

Post by Kwevin » 28 May 2017 08:15

Yay! *extremely enthusiastic cheering* A million thanks, Melarec! It works, you're a genius!

Could you explain about the global and alias?
Alea iacta est. Serius regredi est.

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Math

Post by Kwevin » 28 May 2017 08:17

(3 days for a calculator. *amuse*) Oh, and 7500 coppers is 4 plat, 4 gold, 1 silver.
Alea iacta est. Serius regredi est.

User avatar
Melarec
Rising Hero
Posts: 318
Joined: 29 Feb 2016 19:51
Location: Everywhere
Contact:

Re: Math

Post by Melarec » 29 May 2017 04:42

Kwevin wrote:Yay! *extremely enthusiastic cheering* A million thanks, Melarec! It works, you're a genius!

Could you explain about the global and alias?
Yay! I wouldn't say genius, but.. :P Glad it works.
By Global, I meant the first line where you first define "copp"
As for alias, I meant to tie the code to an alias like "coinCalc"
And what I meant by all this was to change the number in the first line whenever you wanted to calculate the coins and use the alias to execute the code.

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Math

Post by Kwevin » 29 May 2017 04:55

Oh, like actually modify the value in the code each time?

Eh, sounds cumbersome, if so. That's what I'm doing now, and I don't want that. After reading something else, I think I have to use an arg.
Could I reference a trigger somehow, with gwc.userdata.triggername? Think I've seen people doing it with aliases.
Alea iacta est. Serius regredi est.

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/