Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^4: Return full line from line number X

by Rathlar (Initiate)
on Oct 27, 2008 at 02:51 UTC ( #719696=note: print w/replies, xml ) Need Help??

in reply to Re^3: Return full line from line number X
in thread Return full line from line number X

no... there will be a list on a php page which will be numbered according to thier line position in the file... so i'll paste a couple lines from the file so you can get a better idea...

258 Phontom Fungus
266 Yeth Hound
267 Mennlock
269 Medium Earth Elemental

the numbers represent the monster's attack value ($mnum) and the name is obviously $mname

now lets say these are lines 51-54... lets say a player put in the command to battle $mline which in this case would be 53

so $mline = 53 now which is the line i need to snag and then split to get the proper values.

most of the other code in here doesn't really have anything to do with what I'm doing... its about 4k lines of code... but i could give you an example of the player sending the command via IRC... this would be the command that i'm making which would trigger the sub that I originally asked for help with.

elsif ($arg[3] eq "battle") { if (!defined($username)) { privmsg("FIGHT Request Denied: You are not logged +in.", $usernick); } elsif ($rps{$username}{level} < 15) { privmsg("BATTLE Request Denied: Command available +to level 15+ users only.", $usernick, 1); } elsif ($arg[4] > 551) { privmsg("FIGHT Request Denied: This monster does n +ot exist.", $usernick, 1); } elsif ($arg[4] < 1) { privmsg("FIGHT Request Denied: This monster does n +ot exist.", $usernick, 1); } elsif (itemsum($username) > $arg[4]($mnum)) { privmsg("FIGHT Request Denied: Pick a harder monst +er!", $usernick, 1); } else { monster_battle($username, $arg[4]); } }
basically most of it is just a bunch of checks to make sure the fight is possible... once we determine that, to starts the monster_battle sub pitting the player against the monster that was specified. $arg4 is the input the player gives which in this case should be the line number 53 meaning that the player wishes to fight with a "Mennlock" with an attack rating of "267"

the line numbers will only be supplied on the php page which is just a quick reference to the player so that they can just type /msg botname battle 53

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://719696]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-05-26 12:18 GMT
Find Nodes?
    Voting Booth?