ID:1335407
 
(See the best response by Albro1.)
Problem description:
This is not really a problem, but I was wondering how I would call a constant string of text into a user's output. For example

Code:
mob
proc

item_price(item/item, cost)
src << "[cost] [Constants.MONEY] is required to purchase [item]."


Where Constants.MONEY is "Dollars". I was wondering if this would work or would I have to call it another way. I'm asking because I'm not sure what I want my currency name to be as of now.



Best response
I'm not sure what you are asking. Of course if you have a variable like this:

var/const/currency = "Dollars"


Then you could reference it like so:
mob/proc/item_price(item/item, cost){src << "[cost] [currency] is required to purchase [item]."}
Alright. But what I am referring to is my list of Constants. Constants is a Datum and under it, several constants are defined such as INTERACTION_KEY = "Space" and whatnot

I have under my Constants Datum, a MONEY variable which is defined as MONEY = "Dollars"

So to reference it as an output to a user, I was wondering if I could do (see code above)
In response to SilencedWhisper
As long as you have an actual existing reference to a Constants object, then it'll work.
Not sure why you would create an object to store these variables, but yeah, what LA said.
In response to SilencedWhisper
SilencedWhisper wrote:
Alright. But what I am referring to is my list of Constants. Constants is a Datum and under it, several constants are defined such as INTERACTION_KEY = "Space" and whatnot

I have under my Constants Datum, a MONEY variable which is defined as MONEY = "Dollars"

So to reference it as an output to a user, I was wondering if I could do (see code above)

Maybe you could shift this system over into an associative list defined for world. Then you can add these attributes to it, then call them up in code.

Constants[INTERACTION_KEY]="Space"
Constants[CURRENCY]="Dollars"
//etc.


Then, you can just reference it as such:

src << "[cost] [Constants[CURRENCY]] is required to purchase [item]."
I think he is using a Datum as a namespace, which is fine
I am partially following the Action RPG Framework by Forum_account... And he has a constants file defining certain constants for ease in coding.

Thanks for the help.