What's wrong with this prog?

Posted by Zeno on Thu 28 Jul 2005 09:36 PM — 9 posts, 33,299 views.

USA #0
>speech_prog "test 1"
if iscarrying($n) == 154
else
if iscarrying($n) == 14
if iscarrying($n) == 1011
if iscarrying($n) == 15
if iscarrying($n) == 20
mpforce $n give arm Slooguntitsu
mpjunk arm
mpforce $n give leg Slooguntitsu
mpjunk leg
mpforce $n give wood Slooguntitsu
mpjunk wood
mpforce $n give mushroom Slooguntitsu
mpjunk mushroom
mpoload 151
give crystal $n
endif
endif
endif
else
mea $n Slooguntitsu says "You do not have the items! Go get them!"
endif
endif


If I have the wood, arm and leg, and say the syntax, the mob will do nothing at all.
Amended on Thu 20 Jul 2006 09:32 PM by Zeno
USA #1
I don't think you are supposed to put quotes around the syntax you want it to match. Test it with the quotes and see what he does.
USA #2
No, heh, the prog works fine else if you have the all the items etc. Quotes are fine.
#3
>speech_prog "I have the items"
if iscarrying($n) == 154
else
if iscarrying($n) == 14
if iscarrying($n) == 1011
if iscarrying($n) == 15
if iscarrying($n) == 20
mpforce $n give arm Slooguntitsu
mpjunk arm
mpforce $n give leg Slooguntitsu
mpjunk leg
mpforce $n give wood Slooguntitsu
mpjunk wood
mpforce $n give mushroom Slooguntitsu
mpjunk mushroom
mpoload 151
give crystal $n
endif
endif
endif
else
mea $n Slooguntitsu says "You do not have the items! Go get them!"
endif
endif


Meh. This is ugly formatting. Let us do it the Python way to show you your problem:

>speech_prog "I have the items"
if iscarrying($n) == 154
else
> if iscarrying($n) == 14
    if iscarrying($n) == 1011
      if iscarrying($n) == 15
        if iscarrying($n) == 20
          mpforce $n give arm Slooguntitsu
          mpjunk arm
          mpforce $n give leg Slooguntitsu
          mpjunk leg
          mpforce $n give wood Slooguntitsu
          mpjunk wood
          mpforce $n give mushroom Slooguntitsu
          mpjunk mushroom
          mpoload 151
          give crystal $n
          endif
         endif
       endif
   else
      mea $n Slooguntitsu says "You do not have the items! Go get them!"
      endif
   endif


If you look at the program, I think the last else is tied to the if statement that I marked with an ">". Your problem should be there.

Test your program out without whatever object is vnum 14. If it displays the correct error message, then you have a problem with the logic of the code.
USA #4
How would I have the prog require all the items then? This actually isn't a prog I did, but I'm wondering.
#5
Isn't there some conjuction or union operator in SMAUG mobprogs? Cannot you go something like:

if hasobj(1) && hasobj(2) ...

?
USA #6
Not that I know of. I know you can do something with or:
if hasobj(400)
or
if hasobj(401)

But that's it. Let me know if there's an and statement I don't know about.
USA #7
SMAUG mobprogs are extremely limited. If you go look at the code, you'll see that it's not really a programming language at all. There is an 'or' but I don't believe there's an 'and'.
#8
I realize this is an old post and you've probably already discovered your mistakes by now. Still, it turned up in my search from Google, so I'll go ahead and answer it.

The way your original program is written, you will only get the success actions if you have ALL 4 items, and you will only get the fail message if you are missing the item numbered 14.

I'm not terribly familiar with mob progs, but if you put the else mea ... after each if clause and then break, it should work. This means a total of 4 else statements, not counting the first one.

The other possibility is if mob progs have a negation ability, so that you could ask if a player doesn't have 14, or a player doesn't have 1011, or ... then fail else success.