# Make SURE there is no BOM in this file! It causes functions to be seen as non-existent! # This rebuilds the hazard list. sub rebuildSpaceballs { clear(@hazards); local('@data'); $file1 = openf("botvgh/hazards/spaceballs.txt"); @data = readAll($file1); closef($file1); for ($i = 0; $i < size(@data); $i++) { this('$line'); $line = @data[$i]; if (left("$line", 8) eq "COMMENT ") { removeAt(@data, $i); $i--; } } for ($i = 0; $i < size(@data); $i = $i + 2) { this('%haz'); %haz = %(id => "spaceballs", hz => @data[$i], fx => @data[($i + 1)]); push(@hazards, %haz); #push(@hazards, @(@data[$i], @data[($i + 1)])); } return; } # This gets a random hazard and returns it. # Well...if $1 isn't -1, then it goes for that specific. sub getHaz { local('$A $B $C $big %temp'); $big = size(@hazards); if ($1 == -1) { $1 = rand("$big"); } %temp = @hazards[$1]; $A = "Spaceballs #$1 out of $big is:"; # echo(%temp["hz"]); $B = eval(%temp["hz"]); # "\bThe Spaceballs Ship Arrival\b." $C = eval(%temp["fx"]); # "It's freaking huge! Everyone stops to watch as the ship makes its way past the arena. 20 ticks pass during this scene." return "$A $B $C"; # This isn't returning right at all. Ideas? } global('@hazards'); setProperty("client.encoding", "UTF-8"); rebuildSpaceballs(); #%temp = @hazards[1]; #echo(%temp["hz"]); #echo(@hazards[1][0]); echo(getHaz(1));