Evaluating Strings

DarylHark

New member
Hi all. I'm trying to write a script that basically finds the cheapest of a group of items on the mall and buys one of them. I'm not after specific items so much as I'm trying to learn the basics of scripting as I'm untrained and completely noob. Specifically, I'm using to use the buy() command to parse a variable and buy that item. Here's an example:

String buy_me="Twinkly Wad";
buy (1, buy_me);

That doesn't seem to work. It's as if the buy_me variable isn't being evaluated. I tried:
buy (1, $item[buy_me]); as well as
buy (1, $item[(buy_me)]);

I can replace the integer 1 with a variable and have the command work if I remove the string, for example:

int how_many=1;
buy (how_many, $item[Twinkly Wad]);

I really would like to learn how to pass the string variable into the buy command or learn a new method. I do have zlib.ash if that is important. If anyone can suggest something, I'd very much appreciate it.
 

slyz

Developer
Here is a MafiaWiki article on ASH data types:

Data Types

Basically, the buy( int, item ) function expects the second argument to be an item object. You were passing a string object. The to_item( string ) function returns the item object whose name matches your string.

Another way to make your code work would have been to declare buy_me directly as being an item object:
PHP:
item buy_me = $item[ Twinkly Wad ];
buy( 1, buy_me );
 
Top