mIRC Homepage
Posted By: Sableye2 Help with the goto command - 09/01/07 04:25 AM
I have made this script that uses the goto command. The thing is that I don't think I scripted it properly because it isn't working. I've only worked on the first one so far.

Code:
on *:TEXT:+use * *:#:{
if ($2 == Potion) {
  if  ($readini( $nick $+ .ini,Items,Potion ) >= 1 ) {
if ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon1)))) goto one
elseif ($3 == ($readini($nick $+ .ini,Pokemon2) $readini($nick $+ .ini,Pokemon2)) goto two
elseif ($3 == ($readini($nick $+ .ini,Pokemon3) $readini($nick $+ .ini,Pokemon3)) goto three
elseif ($3 == ($readini($nick $+ .ini,Pokemon4) $readini($nick $+ .ini,Pokemon4)) goto four
elseif ($3 == ($readini($nick $+ .ini,Pokemon5) $readini($nick $+ .ini,Pokemon5)) goto five
elseif ($3 == ($readini($nick $+ .ini,Pokemon6) $readini($nick $+ .ini,Pokemon6)) goto six
:one
/set %pokemon1 $readini($nick $+ .ini,Pokemon,Pokemon1)
    /writeini $nick $+ .ini %pokemon1 hp $calc( $readini($nick $+ .ini,Stats,hp) + 20 )
    /writeini $nick $+ .ini Stats Potion $calc( $readini( $nick $+ .ini,Stats,Potion ) - 1  )   
    .notice $nick 20 HP has been healed to your Pokemon.
/unset %pokemon1
  }
  else { notice $nick You Have No Potions Left | halt }
}
}


When I type in "+use Potion Pikachu" the notice message is suppose to appear, but it doesn't. By the way, I've only coded the first goto command for a test to see if it works or not. And if needed, I can post the .ini file that contains the information.
Thanks.
Posted By: xDaeMoN Re: Help with the goto command - 09/01/07 04:40 AM
Looking at your code, I notice the incorrect syntax of your $readini. You can also post the contents of the ini file and explain how the code should really work.
Posted By: Sableye2 Re: Help with the goto command - 09/01/07 04:49 AM
Okay, here's the .ini file. We will be ignoring about half of it.

Code:
[Name]
Sableye=yes
[Stats]
hp=140
mhp=140
Money=498000
level=1.5
Pokemon=none
amove=none
trng=yes
[Pokemon]
Pokemon1=Pikachu
Pokemon2=Charmander
[Pokemon_Moves]
Pokemon1=Thundershock
Pokemon2=Scratch
[Items]
Potion=1
Revive=2
RareCandy=1
FullHeal=1
[Pikachu]
hp=140
mhp=140
level=1.5
Pokemon1=yes
Thundershock=yes
[Charmander]
hp=50
mhp=100
level=1
Pokemon2=yes
Scratch=yes


We are going to be focusing on the Pikachu part. Here's what should happen:

I type in: +use Potion Pikachu
The script then looks at the .ini file and finds that Pokemon1 = Pikachu. Because of that, we then jump down (this is where the goto command takes place).
An additional of 20 points is added to the HP (health). This is where the notice message should appear.

I hope this makes sense. I've modified the code a bit, not too much though.

Code:
on *:TEXT:+use * *:#:{
if ($2 == Potion) {
  if  ($readini( $nick $+ .ini,Items,Potion ) >= 1 ) {
if ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon1)))) goto one
elseif ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon2)))) goto two
elseif ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon3)))) goto three
elseif ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon4)))) goto four
elseif ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon5)))) goto five
elseif ($3 == ($readini($nick $+ .ini,Pokemon $readini($nick $+ .ini,Pokemon6)))) goto six
:one
/set %pokemon1 $readini($nick $+ .ini,Pokemon,Pokemon1)
    /writeini $nick $+ .ini %pokemon1 hp $calc( $readini($nick $+ .ini,Stats,hp) + 20 )
    /writeini $nick $+ .ini Stats Potion $calc( $readini( $nick $+ .ini,Stats,Potion ) - 1  )   
    .notice $nick 20 HP has been healed to your Pokemon.
/unset %pokemon1
  }
  else { notice $nick You Have No Potions Left | halt }
}
}
Posted By: Riamus2 Re: Help with the goto command - 09/01/07 05:21 AM
Your main problem, as mentioned, is the incorrect format for $readini. $readini requires 3 pieces... filename, topic, item. Your first code was filename and item. Your second one is filename and topic.

/help $readini
Posted By: Sableye2 Re: Help with the goto command - 10/01/07 11:31 AM
Thanks, I found the $readini errors and fixed it. I have one more question though.

Here is a line of code from the script:

Code:
/writeini $nick $+ .ini %pokemon1 hp $calc( $readini($nick $+ .ini,%pokemon1,hp) + 20 )


It adds 20 to the first Pokemon (which happens to Pikachu).
The .ini file has something like this:

[Pikachu]
hp=180
mhp=140

I want it so that it hp that gets added on can't exceed the mhp (maximum HP). How would I do that? For example, if the hp was 110 and the mhp was 140, then the hp would be 130 afterwards. However, if the hp was 130 and the mhp was 140, then afterwards the hp would be 140.
Posted By: Kardafol Re: Help with the goto command - 10/01/07 11:49 AM
Use this:
Code:
if ($calc($readini($nick $+ .ini,%pokemon1,hp) +20) > $readini($nick $+ .ini,%pokemon1,mhp)) {
 /writeini $nick $+ .ini %pokemon1 hp $v2
}
else {
 writeini $nick $+ .ini %pokemon1 hp $v1
}

It should work, but its untested.
Posted By: RusselB Re: Help with the goto command - 10/01/07 11:24 PM
An alternative suggestion
Code:
.writeini $+($nick,.ini) %pokemon1 hp $iif($calc($readini($+($nick,.ini),%pokemon1,hp) + 20) > $readini($+($nick,.ini),%pokemon1,mhp),$v2,$v1)
© mIRC Discussion Forums