Page 3 of 3

Re: Math

Posted: 27 May 2017 01:00
by Melarec
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

Re: Math

Posted: 27 May 2017 02:02
by Tarax the Terrible
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

Re: Math

Posted: 28 May 2017 06:22
by Kwevin
That is possible. Anything is possible with code! :D In all seriousness, I unfortunately can't tell you. I'm not experienced with code.

Re: Math

Posted: 28 May 2017 06:30
by Kwevin

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?

Re: Math

Posted: 28 May 2017 07:43
by Melarec
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.

Re: Math

Posted: 28 May 2017 08:15
by Kwevin
Yay! *extremely enthusiastic cheering* A million thanks, Melarec! It works, you're a genius!

Could you explain about the global and alias?

Re: Math

Posted: 28 May 2017 08:17
by Kwevin
(3 days for a calculator. *amuse*) Oh, and 7500 coppers is 4 plat, 4 gold, 1 silver.

Re: Math

Posted: 29 May 2017 04:42
by Melarec
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.

Re: Math

Posted: 29 May 2017 04:55
by Kwevin
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.