Ironworks Gaming Forum

Ironworks Gaming Forum (http://www.ironworksforum.com/forum/index.php)
-   Dungeon Craft - RPG Game Maker (http://www.ironworksforum.com/forum/forumdisplay.php?f=20)
-   -   Script debugging (http://www.ironworksforum.com/forum/showthread.php?t=101489)

SilentThief 05-22-2010 03:42 PM

Script debugging
 
So, I know we have a few people who are more script savvy than me, and I was wondering what I was doing wrong with this script:

$VAR Count;
Count = 0;

$WHILE (Count < ($MINUS($PARTYSIZE(), 1)))
{
$SET_CHAR_STATUS(Count, "2");
Count = (Count + 1);
};
$RETURN;

Theoretically, it should run thru a loop making each character status "2" (dead) in the party and end when reaching the partysize. But it does not, and I get a GPDL error saying 11 members in party is illegal. This means that the script is failing to exit the loop (as in stop loop when count is no longer lesser than partysize -1).

Any ideas?
ST
ps, does this also mean we may someday have 10 people in the party???

manikus 05-22-2010 05:35 PM

Re: Script debugging
 
Well, first off, DC doesn't support $WHILE - maybe you can use it in a conversation (talk.bin) which uses GPDL in a slightly different way (more can be done).

Second thing I notice is that you don't need to use $MINUS, and in fact shouldn't. I'll let Paul explain why. :) It should just be $PARTYSIZE()-#1

Third, $SET_CHAR_STATUS is used wrong - it needs an actor
$SET_CHAR_STATUS($Target(),"2")

Lastly, it's not an error, but you don't need $RETURN, it's implied.

I just don't know how to make this loop. :(

But, if the idea is to kill the whole party, by setting their status to "2" and not giving damage, you should try using a party ASL - since it effects the whole party. ;)

Paul Stevens 05-22-2010 10:11 PM

Re: Script debugging
 
$VAR Count;
Count = 0;

//Nice. Declare a variabel named 'Count' and set it to "0".
// Remember!!!!!! Everthing in GPDL is a string. (White
//lie alert!). At any rate.....GPDL kindly converted the
//zero to a string, saving you two keystrokes and the
//associated shifts.


$WHILE (Count < ($MINUS($PARTYSIZE(), 1)))

//Not too bad.....Let us say the party size is
// three. That is "3". Remember everthing is a
//string. But $MINUS converts strings to numbers
//and back again....So the result is "2".
//This works pretty well....even though you
//meant to compare numbers, you were actually
//comparing strings. Nevertheless, "0" is less
//than "2". "1" is less than "2". In dictionary
//order. So all is well. If the numbers had gotten
//as high as ten, however, we would find that
// "10" is less than "2".
// Perhaps you should have used a numeric
//comparison rather than a string comparison.
// Count <# ($MINUS($PARTYSIZE(), 1))
// And Manikus is right. $MINUS is designed to
// operate on very large numbers. It would be
// a rather slow and inefficient way to subtract
// small numbers ( less than about 2 billion ).

{
$SET_CHAR_STATUS(Count, "2");

//Now it gets complicated. What is count? It
//can mean one of two things!!!!! Neither of which
//is what you want!
//
// In combat it is the combatant number. It probably
//will be equal to 0, 1, 2, 3, etc for the party
//and then continuing with higher numbers for the
//monsters. But you should not count on it.
//
// In adventure it is the unique id of the party
//member and could be anything. 12, 22, 97, 103.
//

Count = (Count + 1);

//Here, my friend, is the big mistake. Remember that
//everything is a string. "0" + "1" is "01";
//"01" + "1" is "011".
//
// You should probably use an arithmetic plus...
// Count = (Count +# 1);

};
$RETURN;

SilentThief 05-23-2010 07:39 AM

Re: Script debugging
 
Quote:

Originally Posted by Paul Stevens (Post 1240265)

Count = (Count + 1);

//Here, my friend, is the big mistake. Remember that
//everything is a string. "0" + "1" is "01";
//"01" + "1" is "011".

And hence the partymember 11 reference in the error message. gotchya. While GPDL is a computer language and it shows its similarity to C (and C++ which I'm a noob at) and perhaps Basic (which I know real well), it has its differences; and being that EVERYTHING is a string is something that cannot be stressed enuff. I think this has been the problem with all my scripts that should have worked in the past but didn't.

So, I'm to assume a properly set up $WHILE statement won't work fine? are there other loop processes? FOR/NEXT? or GOTO/GOSUB? I know there were functions that GPDL can use that were not listed in the old help file (wherever that may be ;)), and I just got a copy of my old attempt at cataloging all of them, and I can list some if you want (like CONTINUE and RESPOND, from the conversation ability of GPDL). Of course, you prolly know more about it than me since you wrote it ;)

Thanx for the help! Chances are, I'll have a few more posts to this in the near future :D
ST

Paul Stevens 05-23-2010 09:41 AM

Re: Script debugging
 
Quote:

So, I'm to assume a properly set up $WHILE statement won't work fine?
Why not? It should work. If it doesn't,
we'll fix it. $WHILE is documented and
has worked for me.

Your problem is that the party members are
not necessarily numbered 0,1,2,3. Except in
combat. You did not say whether youir script
was designed for a combat setting. We very
definitely need to do something about this
because the documentation is wrong and it
is most confusing for you , me, and anyone
attempting to create scripts.

In combat, there is a function to get the
next combatant and you can put it into
a $WHILE loop until there are no more.
$WHILE (next) {};
Perhaps we should do the same for the
adventuring party. and attempt to change
the documentaion. And add lots of
warnings to the documentation!!!! Because
the simple 0,1,2,3....method will appear to
work well most of the time!!! Perhaps I
should change the code to make 0,1,2,3
NEVER work.

The problem is that the current code allows
a party member to retain his identity as
other party members come and go. If, for
example, there are members 0, 1, 2, and
3 and party member (1) leaves the party,
then party members (2) and (3) retain their
identity and party member (2) is missing.
So the party size will become three and
the members become 0,2,3. Is this valuable?
Perhaps we should change the code so that
it is much simpler. After party member (1)
leaves then the identity of (2) and (3) will
become (1) and (2).

Oh, dear......difficult choices.

SilentThief 05-24-2010 07:13 AM

Re: Script debugging
 
The $WHILE script example I gave was not used for combat, it was only used for just walking around.

Quote:

Originally Posted by Paul Stevens (Post 1240269)

The problem is that the current code allows
a party member to retain his identity as
other party members come and go. If, for
example, there are members 0, 1, 2, and
3 and party member (1) leaves the party,
then party members (2) and (3) retain their
identity and party member (2) is missing.
So the party size will become three and
the members become 0,2,3. Is this valuable?
Perhaps we should change the code so that
it is much simpler. After party member (1)
leaves then the identity of (2) and (3) will
become (1) and (2).

That seems strange. I mean, I don't think that was how that was supposed to be done. I don't know, though. The documentation from the last version was a little unclear about how to reference a partymember (I'm going by memory, as I have the newer beta version and windows 7 does NOT supprt .hlp files). I swear I remember something like

$GIVE_CHAR_ITEM(0, "Wimpy Axe");

would give the first partymember (slot zero) the axe and also reading that it would give the active partymember the axe. But you are saying that if a member of the party were removed from the game then the designer could give a call to give an item to that member of the party?
Wouldn't that throw an error message? referring to a non-existant partymember?

Using your example, in my opinion the references should reset to 0,1,2 instead of having partymembers 0,2,3. But again, thats my opinion.

ST

Paul Stevens 05-24-2010 09:57 AM

Re: Script debugging
 
Well, sir, I have been pondering
this for the last 24 hours or so.
I have come to agree with you.

I very much doubt that anyone
has taken advantage of the unique
identity provided by the code. If
some existing script depends on it,
I will provide conversion functions.

Here is a little 'gotcha'. We will change
this to be party index rather than
PC id. Let us say you do the following:

size = $PARTYSIZE
$WHILE(index <# size)
{
------
$IF (index == 1) delete party member 1
-------
index = index +# 1;
};

Do you see what happens?
Your code never examines party
member(2). Do you see why?
And you will get an error when the
index exceeds the partysize. Do
you see why?
But I suppose scripts are unlikely
to get caught in such traps.

Until you get a version that uses
index rather than id, you can probably
proceed as if it were indexes because
things only get screwed up if a party
member leaves the party and no other
is added.

manikus 05-24-2010 04:16 PM

Re: Script debugging
 
So, Ive never gotten $WHILE to work in the editor or engine, but I have gotten it to work in the conversation feature (talk.bin).

As it's been a while, I should try again. :) I have noticed that in the latest version of the editor, that $WHILE is not listed as a possibility in the script editor.

I'll let you know...I'm gessing that I just wrote a bad script before, with lots of variations that were also bad. ;) Now, I will use a good script. :D


All times are GMT -4. The time now is 04:39 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved