I need some file_to_map help

DaMaster0

Member
Here's the function I have:

Code:
string[int] can_buy_trophies()
{
	string[int] map_of_trophies;
	string[int] we_have;
	int we_on = 0;
	int i = 0;
	string trophies = visit_url("trophy.php");
	if (!file_to_map("Trophy.txt", map_of_trophies))
	{
		abort("There was a problem loading the trophies.");
	}
	while (i < count(map_of_trophies))
	{
			if (contains_text(trophies, map_of_trophies[i]))
			{
				print("The trophy "+map_of_trophies[i]+" is ready for pickup.", "green");
				we_have[we_on] = map_of_trophies[i];
				we_on = we_on + 1;
			}
			i = i + 1;
	}
	return we_have;
}

and this main:

Code:
void main()
{
	string[int] pies = can_buy_trophies();
	foreach i in pies
		print(pies[i]);
}

and it just output this:

> mylib
(repeat this next part 50,000 times)The trophy is ready for pickup.(stop repeating)
it worked

and I do have a trophy:
1znwtww.jpg

does anyone know what i'm doing wrong?
 

Attachments

  • Trophy.txt
    2 KB · Views: 46

Bale

Minion
First of all, Trophy.txt is a mess. All it should contain is your fields separated by tabs. All that other stuff doesn't belong there at all.

Secondly, you start checking with map_of_trophies[0] when your map starts with map_of_trophies[1] (or at least it would start with 1 if your map file was functional).

There might be more problems, but I'm done checking.
 
Last edited:

Grotfang

Developer
Yes. Bale is absolutely correct. I have attached a modified trophy.txt for you. I added a

Code:
0      none

to the map, as you start at 0 and that should have a value. Other than that, I simply removed the \ after every entry (which was fucking up your script) and also cleared away the mess at the top. Works fine (even if it did cost half a million to qualify for one of the few trophies I could get without ascending while in a stupor ;))
 

Attachments

  • Trophy.txt
    1.7 KB · Views: 23
  • test.ash
    640 bytes · Views: 25
Top