Multiple object delivery

For builders to discuss and ask building questions.
Post Reply
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Multiple object delivery

Post by Lathlain » Tue Jun 27, 2006 6:35 pm

I'm probably making a blindingly stupid mistake, but I'm having great difficulty writing a quest whereby 24 objects have to be handed in before the quest will receive. Currently I've got something like this:

>give_prog i110347~
if quest(5,8,$n) >= 1
if quest(5,8,$n) <=25
mpjunk $o
sayto $n I still need more
mpadd $n quest 5 8 1
else
ifquest(5,8,$n) ==26
sayto $n I need another twenty
mpset $n quest 13 8 1
endif
else
if quest(13,8,$n) >= 1
if quest(13,8,$n) <=21
mpjunk $o
sayto $n Keep them coming.
mpadd $n quest 13 8 1
else
ifquest(13,8,$n) ==22
mpecho {80}$I examines the items
sayto $n That will do for now.
mpset $n quest 13 8 23
endif
endif
~

I can get to the first bit, and the giving of the item to the NPC, but he won't stop at 24. What am I doing wrong?...
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Tue Jun 27, 2006 6:59 pm

First, let's rewrite it with correct format.

Code: Select all

>give_prog i110347~
if quest(5,8,$n) >= 1
  if quest(5,8,$n) <=25
    mpjunk $o
    sayto $n I still need more
    mpadd $n quest 5 8 1
  else
    if quest(5,8,$n) ==26
      sayto $n I need another twenty
      mpset $n quest 13 8 1
    endif
  else  <------ here is a problem... we already have an "else" at that level.
if quest(13,8,$n) >= 1
  if quest(13,8,$n) <=21
    mpjunk $o
    sayto $n Keep them coming.
    mpadd $n quest 13 8 1
  else
  if quest(13,8,$n) ==22
    mpecho {80}$I examines the items
    sayto $n That will do for now.
    mpset $n quest 13 8 23
  endif
endif
~ 
Last edited by Dalvyn on Tue Jun 27, 2006 7:05 pm, edited 1 time in total.
Image
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Tue Jun 27, 2006 7:02 pm

There might be a problem with the limits you use : quest bit >= 1 and quest bit <= 25 means that it will trigger for quest bit being any value amongst

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, and 25

Counting them, you will see that there are 25 numbers there... so, it will trigger 25 times (while you only want it to trigger 24 times).

It should thus be: quest bit >= 1 and quest bit <= 24 if you want it to trigger only 24 times.
Image
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Tue Jun 27, 2006 7:05 pm

*Ahem*
Beg yer pardon!
It's properly formatted in my file, but copying/pasting it to the forum seems to have flattened it. Sorry about that!

I think it was the two 'ifs' to start with that confused me.
Thankyou though!
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Tue Jun 27, 2006 7:06 pm

No problem :)

You can enclose your program excerpts in [ code ] ... [ /code ].
Image
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Tue Jun 27, 2006 10:57 pm

I'm actually still experiencing some issues with this, at least in the first bit.

Code: Select all

>give_prog i110347~
if quest(5,8,$n) >= 1
  if quest(5,8,$n) <=24
    mpjunk $o
    sayto $n I still need more
    mpadd $n quest 5 8 1
  else
    if quest(5,8,$n) ==25
      sayto $n I need another twenty
      mpset $n quest 13 8 1
    endif 
I can hand any amount of items in and receive the 'I still need more' message, but he will refuse to stop at 24 (Or 25, in the first case ;-)). It just seems to be that the quest is never reaching 5 8 24 for whatever reason. Have I got the syntax right?
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Zach

Post by Zach » Wed Jun 28, 2006 2:43 am

now... i have NO idea about FK coding... but i do know about C++ and it looks quite the same (some things)
you have

Code: Select all

>give_prog i110347~ 
if quest(5,8,$n) >= 1 
  if quest(5,8,$n) <=24 
    mpjunk $o 
    sayto $n I still need more 
    mpadd $n quest 5 8 1 
  else 
    if quest(5,8,$n) ==25 
      sayto $n I need another twenty 
      mpset $n quest 13 8 1 
    endif
it seams that at the end... you have 13 8 1
and also, you do not have them seperated by , when entering them after mpadd $n quest... i do not think the brackets () are of problem... but they might be...

like i said... i have no idea how to code FK... but just my opinion

EDIT:

so finishing it should read (in my opinion)

Code: Select all

>give_prog i110347~ 
if quest(5,8,$n) >= 1 
  if quest(5,8,$n) <=24 
    mpjunk $o 
    sayto $n I still need more 
    mpadd $n quest 5, 8, 1 
  else 
    if quest(5,8,$n) ==25 
      sayto $n I need another twenty 
      mpset $n quest 5, 8, 1 
    endif 
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Wed Jun 28, 2006 9:45 am

Nope, arguments in a "mpmset $n quest 5 8 1" line do not use commas.

Some things (like the logic behind conditionnal checks and some expressions) are similar to that ugly bad-programmer-friendly error-prone language C, but it's definitely different though. :)

Lathlain, did you get this program to work, or do you still have problems with it?
Image
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Wed Jun 28, 2006 10:24 am

No, I'm still having difficulty with it. I'll post a full version of the code when I get home if that helps any (The quest, that is - Not the whole area!). Otherwise though, everything's finished and ready to test!
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Wed Jun 28, 2006 11:21 pm

As promised, this is the full thing.

Code: Select all

>give_prog i110347~
if quest(5,8,$n) >= 1
  if quest(5,8,$n) <=24
    mpjunk $o
    sayto $n Yes, yes - I still require more though.
    mpadd $n quest 5 8 1
  else
    ifquest(5,8,$n) ==25
	 sayto $n Two dozen precisely... Now let's have a look at these
	 mpecho {80}$I tuts to himself, scowling at the crushed rivets
	 sayto $n No, these will not do at all.
	 sayto $n Half of these are ruined, and the rest of barely useable!
	 sayto $n Bring me another twenty, and I might be able to do 
	 sayto $n something with them. And be careful with them this time!
	 mpset $n quest 13 8 1
    endif
if quest(13,8,$n) >= 1
  if quest(13,8,$n) <=20
    mpjunk $o
    sayto $n Better - Keep them coming.
    mpadd $n quest 13 8 1
  else
    ifquest(13,8,$n) ==21
	sayto $n Right... Let us see how these compare.
	mpecho {80}$I examines the pile of rivets
	sayto $n Not much better... But still. With these and the ones you
	sayto $n brought me earlier, I can probably put them to use.
	sayto $n Humf. That will do for now.
      mpmadd $n exp 1000
      mpmadd $ qp 1
	empecho {80}$I Snorts at $N
	sayto $n I suppose you want some kind of reward for that, eh?
	mpset $n quest 13 8 22
  endif
endif
~
Last edited by Lathlain on Thu Jun 29, 2006 7:55 am, edited 1 time in total.
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Zach

Post by Zach » Thu Jun 29, 2006 12:43 am

could you re edit it with the [ code ] thingie
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Thu Jun 29, 2006 7:17 am

Ok, I guess it would go something like this:

Code: Select all

>give_prog i110347~
if quest(5,8,$n) >= 1
  if quest(5,8,$n) <=24
    mpjunk $o
    sayto $n Yes, yes - I still require more though.
    mpadd $n quest 5 8 1
  else
    ifquest(5,8,$n) ==25 <----- ************
      sayto $n Two dozen precisely... Now let's have a look at these
      mpecho {80}$I tuts to himself, scowling at the crushed rivets
      sayto $n No, these will not do at all.
      sayto $n Half of these are ruined, and the rest of barely useable!
      sayto $n Bring me another twenty, and I might be able to do
      sayto $n something with them. And be careful with them this time!
      mpset $n quest 13 8 1
    endif
    if quest(13,8,$n) >= 1
      if quest(13,8,$n) <=20
        mpjunk $o
        sayto $n Better - Keep them coming.
        mpadd $n quest 13 8 1
      else
        ifquest(13,8,$n) ==21  <----- ************
          sayto $n Right... Let us see how these compare.
          mpecho {80}$I examines the pile of rivets
          sayto $n Not much better... But still. With these and the ones you
          sayto $n brought me earlier, I can probably put them to use.
          sayto $n Humf. That will do for now.
          mpmadd $n exp 1000
          mpmadd $ qp 1
          empecho {80}$I Snorts at $N
          sayto $n I suppose you want some kind of reward for that, eh?
          mpset $n quest 13 8 22
        endif
      endif
~
A first problem might come from the typos on the lines with asterisks (missing spaces between "if" and "quest").

Also, as is visible from the structure (once you add up spaces), you are missing some "endif" there.

You also have another typo in the first part of the program : "mpadd" should be "mpmadd"; later, "mpset" should be "mpmset". And there's another "mpset" near the end.

There's another mistake that will become visible once those are fixed... but that one is for later.

Keep it up. :) You did not really start with a very easy program.
Image
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Thu Jun 29, 2006 7:58 am

Sorry, I posted that last one in a bit of a hurry last night, and completely forgot about [ code ]!
When you point it out like that, it all becomes so blindingly obvious ;-) That said though, I'm dreading the fault that will emerge later ;-)

Thanks for your help! I'll redo this and submit it again when I get home.
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Thu Jun 29, 2006 9:51 am

You sometimes get blind to obvious mistakes when you read the same program again and again, so it helps to get a fresh look.

As for the other error, don't worry too much. It's something that you will notice quickly I think, and that is very simple to fix.
Image
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Post by Lathlain » Thu Jun 29, 2006 10:34 am

I *think* I've ironed it out, but for the endif you say I'm missing - I really can't spot the blighter...

Just to confirm, when I have a:

Code: Select all

if quest(5,8,$n) >= 1 
  if quet(5,8,$n) <=24 
do I need to end it with two endifs?
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Thu Jun 29, 2006 12:17 pm

Yup, you need one "endif" for each "if", so, you would need two endif for the extract you posted above.

Another way to make sure that you do not miss any "endif" is to corretly format the program. If you take a look at the long code above, you will see that the last line of the program starts 4 spaces to the right, which show that there are two missing endifs.
Image
Post Reply