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

Here is a script from DW1

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




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Mon Apr 26, 2004 7:02 pm    Post subject: Here is a script from DW1 Reply with quote

hey check out this script, and tell me if it can be made shorter
basically what it does, lets you buy six keys(inventory(Cool)
if you have more then six keys, it won't let you buy more
also if you don't have money it wont let you buy more keys(naturally, nothing is free)
now the script works find, its just I was wandering if it can be made simpler.
Code:
script, keyshop, begin
variable (t)
setvariable(t,true)
if(currentmap==3) then(
gold:=23) # this checks to see what price to set for the shop(naturally gold is global variable
showtextbox(69)
waitfortextbox
if(checktag(20) == on) then (
   if (inventory(8) << 6) then (
      if (paymoney(gold)) then (
        getmoney(paymoney)
        show textbox(73)
        waitfortextbox
      )
   )
)

while ((t) and (checktag(20)==on) )  do(
wait(1) # this is a little loop to see if you want more keys
showtextbox(71)
waitfortextbox

if(checktag(20) == off) then (
set variable(t,false))
if (paymoney(gold)) then (
getmoney(gold)
),else(setvariable(t,false))
if (inventory(8) >= 6) then (
set variable(t,false))

if(checktag(20) == on) then (
   if (inventory(8) << 6) then (
      if (paymoney(gold)) then ( getmoney(paymoney)
        show textbox(73)
        waitfortextbox
      )
   )
)

)
#this checks what messages to display
if(inventory(8) == 6) then (
showtextbox(72) # this one displays the inventory is full
),else(showtextbox(119) # this one displays the thank you
),else(
if (paymoney(gold)) then (
getmoney(gold)
),else(
showtextbox(118) # this one displays that you are too poor to afford a key
))
           

end


sorry for lack of remarks. I am not very good at it

well tell me what you guys think
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Apr 27, 2004 2:22 am    Post subject: Reply with quote

Almost everything can be simplified. And THAT rambling monstrosity can certainly be simplified.

You say the same thing over and over. I found FOUR instances of

if (paymoney(gold)) then (
getmoney(gold)
)

It shouldn't really not work fine.
while ((t) and (checktag(20)==on) ) do(
should not compile, but if it does, it's easy to see why it still works.
Speaking of this, putting (checktag(20)==on) in the while and then having
if(checktag(20) == off) then (
set variable(t,false))
is redundant.

But I don't quite understand- can you tell us exactly which textbox gives you the item, and what tag 20 does?
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Tue Apr 27, 2004 4:30 am    Post subject: Reply with quote

ok,

if (paymoney(gold)) then (
getmoney(gold)
)
you are right it shouldn't work
it should have been
if (paymoney(gold)) then (
give you item

tag 20==on is actually a choice, of yes, and tag 20 ==off is no

textbox 73 gives you money,
and 71 displays this message (another: yes/no)
again tag 20
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Apr 27, 2004 12:38 pm    Post subject: Reply with quote

ah...

But I meant that
while ((t) and (checktag(20)==on) ) do(
should be
while ((t), and, (checktag(20)==on) ) do(
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Bob the Hamster
OHRRPGCE Developer




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

PostPosted: Tue Apr 27, 2004 9:18 pm    Post subject: Reply with quote

Code:

  while ((t) and (checktag(20)==on) ) do(
  while ((t), and, (checktag(20)==on) ) do(


no, both ways is fine. parenthesis magically imply commas, so Ysoft's method work.

For the same reason, both of the following are exactly the same:

Code:

  if(condition), then, begin
  if(condition) then, begin


Hamsterspeak really provides too much flexibility in syntax. It causes confusion when people share code.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed Apr 28, 2004 12:33 am    Post subject: Reply with quote

Oh, of course! I was so used to putting commas around my and's that I forgot that there are 3 ways of seperating commands..

Looking through it, I am still unconvinced that it works,

Umm, sorry what do you mean that textbox 73 gives you money? Do you prehaps mean that it give you the item? Is so, take out the get item.

Alright, armed with a better understanding of the script, I rewrote it:

Code:

script, keyshop, begin
  variable (t)
  t := true
  if (currentmap == 3) then (gold:=23) # this checks to see what price to set for the shop
  show textbox (69)
  wait for textbox

  while (t) do (
    if (checktag(20), and, inventory(8) << 6) then (
      if (paymoney(gold)) then (
        get item (8)
        show textbox (73)
        wait for textbox
        show textbox (71)  #want another?
      ) else (t := false, showtextbox(118)) # this one displays that you are too poor to afford a key
    )
    if (checktag(20) == false) then (showtextbox(119), t := false) else ( # this one displays the thank you
      if (inventory(8) == 6) then (showtextbox(72), t := false) # this one displays the inventory is full
    )
    wait for textbox
  )         
end


hmmm... I think you should definitly test that - it doesn't seem very stable to me.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Thu Apr 29, 2004 4:35 am    Post subject: Reply with quote

thanks, I will test that,
I rewrote my script another way, and I found out that the while loop doesn't work the way I had expected it to work
appearantly(ok, I am not sure how to spell the word), the while loop doesn't go back up, but instead works like qbasics Do, until, it does the validation check at the end of the statement, and doesn't go up to check it in the begining. I think that is so, and by using my script, it proves my theory.
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Thu Apr 29, 2004 8:01 am    Post subject: Reply with quote

ok, the script works, thanks
_________________
Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Apr 29, 2004 9:14 pm    Post subject: Reply with quote

No, that's wrong. The statement is checked before the first iteration of the while loop, if it works out to false, the do block is never run.

However, "for (i, 0, 0) do (...)" will run once... tricky..
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
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