money utilities #103

Parent #79Owner #36Flags Source RPG Core/rpgcore-patched.db

Aliases: money utilities

5 verbs · 8 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
_has_currencythis none thisrxd#1032
_from_tothis none thisrxd#10312
init_for_corethis none thisrxd#1035
match_orgthis none thisrxd#10317
@add-currencynone at/to thisrd#10311

Properties

PropertyDefinerFlagsOwnerValue
currencies#103r#36{{"gold", 1.0}}
org_matches#103r#36{{"", "gold"}}
help_msg#79rc#36<clear>
key#1c#360
aliases#1rc#36{"money utilities"}
description#1rc#36"Verbs for MOO currency conversion."
object_size#1r#36{4465, -1090650497}
html#1rc#36<clear>

Ancestry

Ancestors (nearest first): #79 Generic Utilities Package#1 Root Class

Children: none

Call graph

calls n103_0 #103:_has_currency n55_16 #55:slice n103_0->n55_16 n103_1 #103:_from_to n103_1->n103_0 n103_1->n55_16 n103_2 #103:init_for_core n1_28 #1:init_for_core n103_2->n1_28 n103_3 #103:match_org n103_3->n55_16 n103_4 #103:@add-currency n103_4->n103_3 n56_2 #56:read n103_4->n56_2 n6_18 #6:tell n103_4->n6_18

Source

_has_currency

Spec this none thisFlags rxdOwner #36Definer #103

Referenced by

Source

1"This function returns whether a currency you specify is contained within the currency list. If so, it will also return the index location. If not, it will return false.";
2return args[1] in $list_utils:slice(this.currencies, 1);

_from_to

Spec this none thisFlags rxdOwner #36Definer #103

Referenced by

Source

1"This function returns the value of currency2 given an amount of currency1.";
2"The function returns a floating point value representing the value in terms of the second .";
3"Takes 3 arguments:";
4"1) String representing the currency to exchange from.";
5"2) String representing the currency to exchange to.";
6"3) Number representing the amount of first currency to translate.";
7if (this:_has_currency(args[1]) && this:_has_currency(args[1]))
8newvalue = (tofloat(args[3]) * this.currencies[args[2] in $list_utils:slice(this.currencies, 1)][2]) / this.currencies[args[1] in $list_utils:slice(this.currencies, 1)][2];
9else
10newvalue = 0.0;
11endif
12return newvalue;

init_for_core

Spec this none thisFlags rxdOwner #2Definer #103

Referenced by

none

Source

1if (caller_perms().wizard)
2this.currencies = {{"gold", 1.0}};
3this.org_matches = {{"", "gold"}};
4return pass(@args);
5endif

match_org

Spec this none thisFlags rxdOwner #36Definer #103

Referenced by

Source

1"USAGE: match_org(STRING) where the string is either a currency or an org name.";
2"       => if arg is an org name, returns STRING - the currency used.";
3"       => if arg is a currency name, returns LIST - the orgs that use it.";
4"       => if arg is neither, returns $failed_match.";
5orgndex = args[1] in $list_utils:slice(this.org_matches, 1);
6curndex = args[1] in $list_utils:slice(this.org_matches, 2);
7if (orgndex)
8return this.org_matches[orgndex][2];
9elseif (curndex)
10orgs = {};
11for pair in (this.org_matches)
12orgs = (args[1] == pair[2]) ? {@orgs, pair[1]} | orgs;
13endfor
14return orgs;
15else
16return $failed_match;
17endif

@add-currency

Spec none at/to thisFlags rdOwner #36Definer #103

Referenced by

none

Source

1"USAGE: @add-currency to $money_utils";
2"This function is run by the wizzen or programmers who wish to add currencies to the system. Follow the prompts.";
3if (player.programmer || player.wizard)
4base = this:match_org("");
5CurName = $command_utils:read("the name of the new currency");
6exch = tofloat($command_utils:read(tostr(("approximately how many " + CurName) + " units are equal to a single unit of ", base, ". Floating point numbers are allowed (ie: .5, 2.0)")));
7this.currencies = {@this.currencies, {CurName, exch}};
8player:tell("The currency has been added to the list.");
9else
10player:tell("You are not allowed to add currencies to the system.");
11endif