 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Posted: Tue Nov 11, 2003 3:24 am Post subject: How do you count heroes? |
|
|
Code: | script, countmyheroes, begin
variable (howmany)
variable (ah)
howmany:=0
for (ah,0,3,1)
do (
if (hero by rank(ah)<>-1)
then (increment(howmany,1))
)
if (howmany==1) then (-do this-)
if (howmany==2) then (-do this-)
if (howmany==3) then (-do this-)
if (howmany==4) then (-do this-)
end |
I want to count the number of heroes in my caterpillar party. This plotscript compiles fine, but it doesn't seem to be working. Have I done something wrong? |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Tue Nov 11, 2003 6:08 am Post subject: |
|
|
hmmm... have you tested it out?
like replace -do this- with textbox(1 hero), textbox(2 heroes) etc...
try and nail where the error is coming from, whether it's in the -do thid- section or the checking itself...
besides, i thought there was a "room in party" command, where it tells you how many room is left in your active party. _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
Cube Dimensional Traveller

Joined: 02 Feb 2003 Posts: 294
|
Posted: Tue Nov 11, 2003 11:50 am Post subject: |
|
|
An autonumber script would be best for this kind of thing. Here's how I'd do it:
Code: |
define script (autonumber, count my heroes, none)
define script (1, example, none)
script, count my heroes, begin
variable (total, loop)
for (loop, 0, 3, 1) do (
if (hero by rank (loop) <> -1) then (
increment (total)
)
)
return(total)
end
script, example, begin
if (count my heroes == 1) then (
DO THIS
)
if (count my heroes == 2) then (
DO THIS
)
if (count my heroes == 3) then (
DO THIS
)
if (count my heroes == 4) then (
DO THIS
)
end
|
It looks longer, but in the long run it'll save you time. What happens is that by doing it this way you can count your heroes at any time now without having to write a for loop again. I don't know if you'll ever need to again, but it's nice knowing that this alternative exists, eh? Study this well though, because autonumber scripts are a must for more complex stuff (And we all want cool scripts, don't we? Heheh).
Oh, and by the way. There was no need to do a "howmany:=0". ALL variables are 0 by default, so you don't have to worry about setting them to that.
....I hope I showed enough. If you have any questions on how this works, just ask. That's what I'm here for, to help explain plotscripts . |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue Nov 11, 2003 12:13 pm Post subject: |
|
|
Flamer wrote: |
besides, i thought there was a "room in party" command, where it tells you how many room is left in your active party. |
That is absolutely correct. -- er, almost correct. The name of the command is room in active party
Code: |
define script(autonumber, active hero count,none)
script, active hero count, begin
return(4 -- room in active party)
end
|
|
|
Back to top |
|
 |
Cube Dimensional Traveller

Joined: 02 Feb 2003 Posts: 294
|
Posted: Tue Nov 11, 2003 11:43 pm Post subject: |
|
|
James Paige wrote: | Flamer wrote: |
besides, i thought there was a "room in party" command, where it tells you how many room is left in your active party. |
That is absolutely correct. -- er, almost correct. The name of the command is room in active party
Code: |
define script(autonumber, active hero count,none)
script, active hero count, begin
return(4 -- room in active party)
end
|
|
Doh! I absolutely forgot that command!
* Cube hangs his head *
Geez . |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Wed Nov 12, 2003 2:56 am Post subject: |
|
|
heh, it's alright even genius' forget what 1+1 is for a second. (i'm not being serious, but is very possible... einstein did, forget that is...)
at least we learn something today.  _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|