Script: Counting your forgings

General discussion about the Genesis Web Client located at https://www.genesismud.org/play/

Moderator: Eowul

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
Eowul
Wizard
Posts: 106
Joined: 03 Mar 2010 21:55
Location: Middle Earth

Script: Counting your forgings

Post by Eowul » 30 Aug 2013 19:23

For those Blacksmiths out there, I present you with this trigger and alias that will automatically count the number of items you have forged. Due to the server persistency, this number will be available no matter where you login.

Example of the trigger:

Code: Select all

You have finished forging the platemail greaves.
>>> Total: 101 platemail greaves
And of the alias:

Code: Select all

You have forged the following amounts:
    1  boots
   10  stiletto
    1  bracers
  101  platemail greaves
If you want to initialize the amounts with values you've written down yourself, you can use

Code: Select all

forgecount "item name" 12345
If you use the word remove instead of the number, that specific item gets removed from the list again. Make sure to enter item names in quotes if they contain spaces.

To configure, create a trigger, set it's type to "regexp" and use the following pattern:

Code: Select all

^You have finished forging the (.*)\.$
Then, paste the following code in the script window and set the type to 'javascript':

Code: Select all

if (gwc.userdata.forging === undefined) gwc.userdata.forging = {};
if (gwc.userdata.forging[args[1]] === undefined) gwc.userdata.forging[args[1]] = 0;
gwc.userdata.forging[args[1]]++;
gwc.output.append(">>> Total: " + gwc.userdata.forging[args[1]] + " " + args[1]);
gwc.output.color("#0053B3");
Now, create an alias, name it "forgecount" and paste the following code in the script window, again set the type to javascript:

Code: Select all

if (args[1] !== undefined) {
	if (args[2] == "remove") {
		gwc.output.append("Removed forge count for " + args[1]);
		delete gwc.userdata.forging[args[1]];
	} else if ($.isNumeric(args[2])) {
		gwc.output.append("Set forge count for " + args[1] + " to " + args[2]);
		gwc.userdata.forging[args[1]] = parseInt(args[2], 10);
	} else {
		gwc.output.append("Usage: forgecount \"item\" count/remove");
	}
	return;
}

if (gwc.userdata.forging === undefined) {
	gwc.output.append("No forgings have been counted.");
	return;
}

gwc.output.append("You have forged the following amounts:");
gwc.output.color("#0053B3");
for (var key in gwc.userdata.forging) {
	var count = gwc.userdata.forging[key].toString();
	gwc.output.append("     ".substring(count.length) + count + "  " + key);
}
Caretaker of Arda

Makfly
Champion
Posts: 615
Joined: 04 Mar 2010 00:36

Re: Script: Counting your forgings

Post by Makfly » 31 Aug 2013 09:36

That's pretty neat for the smiths in Genesis, but I cant help wonder why it isn't just coded in the actual game, instead of a Wizard coding it only for a client?

Only argument I can think of right now, is that the Admin wants players to migrate to the official client, and are therefore trying to sweeten the deal by catering to the client rather than the game. Which would be a fair enough, if everyone used the same client, there would be less "outside advantages" like insta-travel via maps, bot-scripts and whatever, but if the Admin doesn't care which client players use, then global, general features like this smith-counter, might as well be available to everyone in-game.
Mortimor Makfly - Gnomish Xeno-Anthropologist

User avatar
Eowul
Wizard
Posts: 106
Joined: 03 Mar 2010 21:55
Location: Middle Earth

Re: Script: Counting your forgings

Post by Eowul » 31 Aug 2013 09:59

Makfly wrote:That's pretty neat for the smiths in Genesis, but I cant help wonder why it isn't just coded in the actual game, instead of a Wizard coding it only for a client?
Genesis as a rule does not display such numbers, that's why it's not available in game. I "coded" this as an example of things that are possible with server persistent triggers, aliases and userdata.
Makfly wrote:Only argument I can think of right now, is that the Admin wants players to migrate to the official client, and are therefore trying to sweeten the deal by catering to the client rather than the game. Which would be a fair enough, if everyone used the same client, there would be less "outside advantages" like insta-travel via maps, bot-scripts and whatever, but if the Admin doesn't care which client players use, then global, general features like this smith-counter, might as well be available to everyone in-game.
/me hands Makfly a tinfoil hat.
Caretaker of Arda

Makfly
Champion
Posts: 615
Joined: 04 Mar 2010 00:36

Re: Script: Counting your forgings

Post by Makfly » 31 Aug 2013 11:43

eowul wrote:Genesis as a rule does not display such numbers, that's why it's not available in game. I "coded" this as an example of things that are possible with server persistent triggers, aliases and userdata.
The official game client does not abide by the same rules as the game?
Okay, a bit weird, but I have no problem with that.
eowul wrote: /me hands Makfly a tinfoil hat.
Huh?
Mortimor Makfly - Gnomish Xeno-Anthropologist

Laurel

Re: Script: Counting your forgings

Post by Laurel » 02 Sep 2013 09:48

eowul wrote:I "coded" this as an example of things that are possible with server persistent triggers, aliases and userdata.
First time in my Genesis life I have a killcount ... never bothered to create one before. Thank you :)
And it's right away all-game total, not just per session ;p

Code: Select all

You killed the swift bicorn.
>>> Total: 3 the swift bicorn

Aristos
Veteran
Posts: 239
Joined: 26 May 2013 18:54

Re: Script: Counting your forgings

Post by Aristos » 12 May 2014 12:02

Is there something similar for herbs?

Laurel

Re: Script: Counting your forgings

Post by Laurel » 12 May 2014 14:53

if I was able to rework this one into a kill count, you can rework it into a herb count ...

Greneth

Re: Script: Counting your forgings

Post by Greneth » 12 May 2014 16:10

Wouldn't it just be easier to use a pouch from the Bree herbalist?

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

Re: Script: Counting your forgings

Post by Kwevin » 23 May 2017 15:24

Is this supposed to persist through multiple logins?
Alea iacta est. Serius regredi est.

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

Re: Script: Counting your forgings

Post by Tarax the Terrible » 23 May 2017 16:14

Yeah I think so, I'm getting random resets to zero tho. You? Wonder if it's stored in your browser and you need some setting tweak
http://genesisquests.pbworks.com/
Join up and help each other with Quests :)

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