mIRC Home    About    Download    Register    News    Help

Print Thread
Help with the goto command #168478 09/01/07 04:25 AM
Joined: May 2006
Posts: 87
S
Sableye2 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
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.

Re: Help with the goto command [Re: Sableye2] #168479 09/01/07 04:40 AM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
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.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Re: Help with the goto command [Re: xDaeMoN] #168481 09/01/07 04:49 AM
Joined: May 2006
Posts: 87
S
Sableye2 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
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 }
}
}

Re: Help with the goto command [Re: Sableye2] #168486 09/01/07 05:21 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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


Invision Support
#Invision on irc.irchighway.net
Re: Help with the goto command [Re: Riamus2] #168554 10/01/07 11:31 AM
Joined: May 2006
Posts: 87
S
Sableye2 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
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.

Re: Help with the goto command [Re: Sableye2] #168555 10/01/07 11:49 AM
Joined: Jan 2007
Posts: 259
K
Kardafol Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
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.


Those who can, cannot. Those who cannot, can.
Re: Help with the goto command [Re: Kardafol] #168602 10/01/07 11:24 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
An alternative suggestion
Code:
.writeini $+($nick,.ini) %pokemon1 hp $iif($calc($readini($+($nick,.ini),%pokemon1,hp) + 20) > $readini($+($nick,.ini),%pokemon1,mhp),$v2,$v1)