Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

How do you count heroes?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Guest







PostPosted: Tue Nov 11, 2003 3:24 am    Post subject: How do you count heroes? Reply with quote

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)

PostPosted: Tue Nov 11, 2003 6:08 am    Post subject: Reply with quote

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 Raspberry!
(no offense to anyone that was mentioned)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Tue Nov 11, 2003 11:50 am    Post subject: Reply with quote

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 Wink.
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Tue Nov 11, 2003 12:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Tue Nov 11, 2003 11:43 pm    Post subject: Reply with quote

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 Oookay... .
Back to top
View user's profile Send private message
Flamer
The last guy on earth...




Joined: 04 Feb 2003
Posts: 725
Location: New Zealand (newly discovered)

PostPosted: Wed Nov 12, 2003 2:56 am    Post subject: Reply with quote

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. Big grin
_________________
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 Raspberry!
(no offense to anyone that was mentioned)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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