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

mini-game script (still need help!!)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Flamer
The last guy on earth...




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

PostPosted: Tue Feb 24, 2004 2:46 am    Post subject: Reply with quote

Code:
walk hero (me,((herodirection(me)+2),mod, 4) ,1)

i suggest revising this part of the code.
because the mod operator should only be returning "false (zero)" or "true (one)"
this means that the hero will only be travelling north or east, as the direction... (found in plotscr.hsd)

maybe you meant.
Code:
walk hero (me,((herodirection(me)+2),divide, 4) ,1)

where it'll return a number...
_________________
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 Feb 24, 2004 8:49 am    Post subject: Reply with quote

While I'm at school and can't check the directional values (I think up is 0, right is 2, left is 1 and down is 3), I can explain the mod function Raspberry!.

Mod never returns 0 or 1 (In the sense of true and false. It can if those numbers are the remainders). You can think of it as a number being subtracted by another number until it can't be subtracted any longer, and the remainder is given. For example:

10, mod, 3

10 is greater than 3, so subtract 3.
7 is greater than 3, so subtract 3.
4 is greater than 3, so subtract 3.
1 isn't greater than 3, so return 1.

Another example:

15, mod, 4

15 is greater than 4, so subtract 4.
11 is greater than 4, so subtract 4.
7 is greater than 4, so subtract 4.
3 isn't greater than 4, so return 3.

Now, it's not like the mod function itself is running a loop that is continuously subtracting the 2nd number from the 1st. That's just the best way I could explain it Raspberry!. If you want to know an equation for it, I guess I could post that too but for now I won't bother since it isn't really that important.

So anyhow, there you go. Using mod was a much better thing to use than divide, but I can't tell how well it really works, heheh.

If you want to do some mod calculations real quick, I have a simple console app that I made:

Mod Calculator
Back to top
View user's profile Send private message
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Tue Feb 24, 2004 6:27 pm    Post subject: Reply with quote

the Mad Cacti's script was working, but i want him to face left from the current direction that he is facing , at the moment he just faces west and the same for right he just east
________
Toyota AD engine history


Last edited by xaero on Thu Feb 03, 2011 7:53 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Feb 24, 2004 11:26 pm    Post subject: Reply with quote

Cube: directions are 0=up, 1=left, 2=down, 3=right. So you can see that (x + 2), mod, 4 returns the opposite direction to any direction.

Flamer: An easier way to invision modulus is as the remainder to a division. 13 / 3 is 4 with a remainder of 1, and

4 * 3 + 1 = 13


As a random side note:
REMEMBER, the 'logic' functions (and, or, xor, etc) supplied with HamsterSpeak are not technically logical funuctions, but bitwise functions. And modulus has a different meaning is mathematics and programming.

Ok, xearo, I didn't think of that. Heres a finished script:

Code:

script,boat,begin
suspend player
set tag(3, on)
while(check tag(3)==on) do(
if (key is pressed(key:left)) then (set hero direction(me,((herodirection(me)+3),mod, 4)))
if (key is pressed(key:right)) then (set hero direction(me,((herodirection(me)+1),mod, 4)))
if (key is pressed(key:down)) then (walk hero(me,herodirection(me),1), wait for hero(me))
if (key is pressed(key:up)) then (walk hero (me,((herodirection(me)+2),mod, 4) ,1), wait for hero(me))
if (hero x == 16, and, hero y == 65) then (set tag (3, off))
wait
)
resume player
end


As the final note, note I used +3 instead of --1 to turn left. -1, mod, 4 would return -3 (I think. Or was it -1?), which is a deadly and annoying 'feature'.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
xaero
me




Joined: 30 Dec 2003
Posts: 101
Location: somewheres

PostPosted: Wed Feb 25, 2004 7:29 pm    Post subject: Reply with quote

Thanks for all the help its finnaly running now, and hopefully i know more about scripts and should be able to figure it out next time
________
Subaru EJ engine history


Last edited by xaero on Thu Feb 03, 2011 7:55 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed Feb 25, 2004 11:48 pm    Post subject: Reply with quote

Few people would know how to/when to/would use the bitwise and math functions for this sort of thing. However, using them can sometimes be a great shortcut.
_________________
"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
Goto page Previous  1, 2
Page 2 of 2

 
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