money utilities #103
Aliases: money utilities
5 verbs · 8 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
_has_currency | this none this | rxd | #103 | 2 |
_from_to | this none this | rxd | #103 | 12 |
init_for_core | this none this | rxd | #103 | 5 |
match_org | this none this | rxd | #103 | 17 |
@add-currency | none at/to this | rd | #103 | 11 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
currencies | #103 | r | #36 | {{"gold", 1.0}} |
org_matches | #103 | r | #36 | {{"", "gold"}} |
help_msg | #79 | rc | #36 | <clear> |
key | #1 | c | #36 | 0 |
aliases | #1 | rc | #36 | {"money utilities"} |
description | #1 | rc | #36 | "Verbs for MOO currency conversion." |
object_size | #1 | r | #36 | {4465, -1090650497} |
html | #1 | rc | #36 | <clear> |
Ancestry
Ancestors (nearest first): #79 Generic Utilities Package → #1 Root Class
Children: none
Call graph
Source
_has_currency
Referenced by
- #91:dr*op line 23:
$money_utils:_has_currency - #91:gi*ve line 32:
$money_utils:_has_currency - #91:conv*ert line 3:
$money_utils:_has_currency - #91:conv*ert line 9:
$money_utils:_has_currency - #103:_from_to line 7:
this:_has_currency - #103:_from_to line 7:
this:_has_currency - #129:payme line 10:
$money_utils:_has_currency - #133:donate line 4:
$money_utils:_has_currency
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
Referenced by
- #91:conv*ert line 12:
$money_utils:_from_to - #91:cash line 13:
$money_utils:_from_to - #129:payme line 3:
$money_utils:_from_to - #133:donate line 9:
$money_utils:_from_to - #134:tell line 18:
$money_utils:_from_to - #134:list line 23:
$money_utils:_from_to - #134:sell line 11:
$money_utils:_from_to - #134:sell_product line 17:
$money_utils:_from_to - #134:sell_product line 17:
$money_utils:_from_to
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
Referenced by
none
Source
1if (caller_perms().wizard) 2this.currencies = {{"gold", 1.0}}; 3this.org_matches = {{"", "gold"}}; 4return pass(@args); 5endif
match_org
Referenced by
- #91:cash line 13:
$money_utils:match_org - #91:cash line 16:
$money_utils:match_org - #103:@add-currency line 4:
this:match_org
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
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