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

Downloadable Plotscript Library
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Fri Sep 05, 2003 1:21 am    Post subject: Reply with quote

I was thinking if one could implement a scripting command to check whether a number is odd or even. I'm having no luck with regular commands. is it actually possible or do I have to define each value individually as odd or even in a domain.
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Fri Sep 05, 2003 2:17 am    Post subject: Reply with quote

I'm actually supposed to be very busy right now, but I somehow ended up with some free time and this was so easy to do, so I quickly slapped it together. Finding out if a number is odd or even if VERY easy. People don't use the mod function enough...

Anyhow, I updated my library with a command that will check if a number is odd or even. However, the actual process of finding it out is so simple that it wasn't really nessisary (But, for those who will ask again in the future, the command will be there for them to learn on their own... Or whatever).

All you have to do is mod the first number by 2:

number, mod, 2

This will return either 0 or 1. If it's 0, then the number is even. If it's 1, then it's odd. Pretty simple, eh?

For my command, it's just this:

is even (number)

Returns true if even, false otherwise Raspberry!. So I dunno. Use whatever you prefer.
Back to top
View user's profile Send private message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Fri Sep 05, 2003 10:45 pm    Post subject: Reply with quote

okay, I delayed in asking that question because I was afraid it was going to be so easy. *just curious* What if the remainder is over 1.5 or something, does the mod function only assess the nicely rounded zeros or does it round up/down on the number 1? A remainder like that is probably unlikely, and knowing me, is probably impossible.
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Sat Sep 06, 2003 12:08 am    Post subject: Reply with quote

You wouldn't get anything but 1 or 0. If you divide any odd number by 2, you'll get a remainder of one, simply because of the fact that any odd number plus one will equal an even number. So no worries there.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Sat Sep 06, 2003 1:25 am    Post subject: Reply with quote

I was a little confused over the number 1, but I guess it is rounded from 0.5 to 1, which makes it odd. I wasn't entirely sure.
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sat Sep 06, 2003 2:35 am    Post subject: Reply with quote

Yeah, the OHR doesn't make use of decimals. 3.4 or 3.8 both work out to be just 3. Or 0.5 or 0.2 both work out to be 0. All numbers get the decimal chopped off. So always ignore decimals when using other tools like a calculator or just working it out on paper.

There is a pretty simple way of rounding decimals when programming in C++ and other languages, but we're not using it so I won't bother getting into that...
Back to top
View user's profile Send private message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Sat Sep 06, 2003 2:55 am    Post subject: Reply with quote

so one would be classed as even? I expected something like that.
just don't ask me how. but I guess one could just use an if block especially for one if it got rounded down.

*yeeeepie*
now I can make those functions I wanted...
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sun Sep 07, 2003 12:00 am    Post subject: Reply with quote

What? No, the number 1 cannot be classified as even. It's an odd number. If you're talking about decimals, I think what you're saying is that one is a whole number. That is, whole numbers are numbers that don't have decimals.

So in the OHR, ALL numbers are whole numbers. 0, 2, 4, 6, 8, 10, 12 are even numbers. 1, 3, 5, 7, 9, 11 are odd. That's what my "is even" function will return... If it's odd or even.

So no, one is cannot be classified as even, heh.

Also, I made a Mod Calculator a couple months ago. Just a tool to quickly check mod calculations. I shoulda posted it earlier, but... Meh.
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed Sep 10, 2003 2:09 pm    Post subject: Reply with quote

Ok, well, I'll have some math funstion scripts to you by the end on tomorrow (rounded divide, square root, sine & cosine..) not because I wrote them for you, but because deriving formulas and testing out the scripts in QBasic was so much damn hard work, I thought I'll share them with you, even if no one but me could see any use in them....
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Sep 13, 2003 3:43 pm    Post subject: Reply with quote

Here they are, delayed by a sudden urge to rewrite the square function (which I did not), and my sister playing AOE2: TC


-----------------
#The Mad Cacti, 2003. Public property

define script, begin

-1, divideround, 2, 0, 1 #Returns the rounded answer to <1st> / <2nd>
-1, sqrt, 1, 0 #Returns the square root.
-1, sine, 2, 100, 50 #Returns <1st> times sine of <2nd>. 50 degrees to a right angle. maximum input: 1st: up to 116, 2nd: anything
-1, sine sqrt, 1, 0 #Optimised square root function usable only by sine script.
-1, cosine, 2, 100, 0 #Same arguments as sine script.
-1, tan, 2, 100, 0 #Note: may return error.

end

define operator, begin #operators for your use, eg '50 + 100, times sine, 50'
25, times sine, sine
25, times cosine, cosine
30, div, divideround
end

define constant (-1, error) #Error is returned by math funstions in some cases.

script, divideround, n, m, begin
if (m == 0) then (return (error)) else (return ((n + m / 2) / m))
end

script, sqrt, fi, begin
variable (start, divi, approx)
if (fi << 0) then (return (error)) else, begin #Can't take the root of a negative
if (fi >= 32761) then (return (181)) else, begin #Prevent overflows
if (fi >= 22500) then (start := 150) else (
if (fi >= 14400) then (start := 120) else (
if (fi >= 8100) then (start := 90) else (
if (fi >= 4225) then (start := 65) else (
if (fi >= 1600) then (start := 40) else (
if (fi >= 900) then (start := 30) else (
if (fi >= 400) then (start := 20) else (
if (fi >= 100) then (start := 10) else (start := 0)
)))))))
while (approx == 0) do, begin
divi := start ^ 2
if (divi >= fi) then (approx := start)
start := start + 1
end
if (divi == fi) then (return (approx)) else, begin
if ((divi -- approx) == fi) then (return (approx -- 1)) else (return (fi / approx + 1))
end
end
end
end

#Sine- angles are 50 measures to a right angle. To convert from degrees: angle = 50 * degrees / 90.
#Multiplier is anything up to 116.
#This is optimised, so don't try to understand it... its looks nothing like the sine formula x - x^3/3! + x^5/5!.. etc
script, sine, mult, angle, begin
variable (mult times angle, sum)
angle := angle, mod, 100 #this part converts the angle to a value between -50 and 50.
if (angle >> 50) then (angle := 100 -- angle)
if (angle << -50) then (angle := -100 -- angle)
mult times angle := mult * angle
sum := ((15 * mult + 2) / 4) * angle #add term 1
sum := sum -- ((sine sqrt ((5 * mult times angle + 4) / Cool * angle + 16) / 32) ^ 2 #add term 2
sum := sum + ((sine sqrt ((mult times angle + 16) / 32) * angle ^ 2 + 506) / 1013) ^ 2 #add term 3
return ((sum + 60) / 120)
end

script, sine sqrt, fi, begin #optimised version of sqrt for sine only
variable (start, divi, approx)
if (fi >= 1369) then, begin
if (fi >= 2916) then, begin
if (fi >= 3969) then (start := 63) else (start := 54)
end, else, begin
if (fi >= 2025) then (start := 45) else (start := 37)
end
end, else, begin
if (fi >= 324) then, begin
if (fi >= 784) then (start := 2Cool else (start := 1Cool
end, else, begin
if (fi >= 81) then (start := 9) else (start := 0)
end
end
while (approx == 0) do, begin
divi := start ^ 2
if (divi >= fi) then (approx := start)
start := start + 1
end
if (divi == fi) then (return (approx)) else, begin
if ((divi -- approx) == fi) then (return (approx -- 1)) else (return (fi / approx + 1))
end
end

script, cosine, mult, angle, begin
return (sine (mult, 50 -- angle))
end

script, tan, mult, angle, begin
variable (temp)
temp := angle, mod, 100
if (temp == 50, or, temp == -50) then (return (error)) else, begin #Tan is undefined at these points
return ((mult * 116, times sine, angle), div, (116, times cosine, angle))
end
end
---------

PS: Cube, I've emailed it to you as well...
..
code tag won't work on long scripts..
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun Sep 14, 2003 2:52 pm    Post subject: Reply with quote

Hmm... why does the end of my message get scrambled? Oh well... all I said was that I was having trouble with the end of my message getting scrambled.

Anway, newer version of sine. Now you can you any value for the angles for sine, cosine and tan. You can use -32600 if you want..

Code:
#Sine- angles are 50 measures to a right angle. To convert from degrees: angle = 50 * degrees / 90.
#Multiplier is anything up to 116.
#This is optimised, so don't try to understand it... its looks nothing like the sine formula x - x^3/3! + x^5/5!.. etc
script, sine, mult, angle, begin
 variable (mult times angle, sum, sign)
 if (angle << 0) then (angle := 0 -- angle, sign := 1) #allow for postive / negative wave nature of graph
 sign := sign + angle / 100
 sign := sign, mod, 2
 angle := angle, mod, 100               #this part converts the angle to a value between 0 and 50.
 if (angle >> 50) then (angle := 100 -- angle)
 mult times angle := mult * angle
 sum := ((15 * mult + 2) / 4) * angle  #add term 1
 sum := sum -- ((sine sqrt ((5 * mult times angle + 4) / 8) * angle + 16) / 32) ^ 2  #add term 2
 sum := sum + ((sine sqrt ((mult times angle + 16) / 32) * angle ^ 2 + 506) / 1013) ^ 2  #add term 3 
 if (sign == 1) then (return (0 -- (sum + 60) / 120)) else (return ((sum + 60) / 120)) #return sum / 120 (rounded)
end


And Cube, I had a look at your library coding, and here's a better version of the 'find value' script for you. Its much faster, and can find the 5 digit of a number.

Code:

script, find value, value, digit, begin

if (Digit >> 5) then (Digit:=5)
return ((value / 10^(digit -- 1)), mod, 10)

end

_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Sun Sep 14, 2003 11:37 pm    Post subject: Reply with quote

nice!

I guess those new sine ratios would come in handy, for platform games and missle command games. If anybody actually thought about it...
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Sep 15, 2003 9:14 am    Post subject: Reply with quote

Missle command... yeah....
The only use I could see for the trig functions was for finding points on a circle:

x or-ordinate = radius, times cosine, angle
y or-ordinate = radius, times sine, angle

Which is why I wrote them..

Note: The square root and other functions always return the correct rounded answer, but the trig functions are sometimes out by 1, particularly for angles close to 50 for sine, and close to 0 for cosine..
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Joe Man




Joined: 21 Jan 2004
Posts: 742
Location: S. Latitude 47°9', W. Longitude 123°43'

PostPosted: Tue Feb 24, 2004 7:12 am    Post subject: Reply with quote

Quote:
If I right-click the link I only get the options Open, Open in a new window, Copy Shortcut, Add to Favorites and Properties. If I go to the file and I right-click in there, I just get options like Back, Select all, Print, and some of the first ones. If I copy and paste it into notepad or word and save it as .lib should it work?

I've had that problem. If your using IE, the only solution I know of is going to "Tools", then "Internet Options", then "Settings", then "veiw files" and go to the bottom of the list. Tedious, but great for taking non-downloadable items off of web pages (hey, they're the ones who put it on my computer!)
_________________
"Everyone has 200,000 bad drawings in them, the sooner you get them out the better."
~Charles Martin Jones

Last edited by Joe Man on Fri Dec 13, 1957 1:21 am; edited 2,892 time in total
Back to top
View user's profile Send private message Send e-mail
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Tue Feb 24, 2004 2:47 pm    Post subject: Reply with quote

Dude, it's been since Sept. 16 from the last post. There's a good chance that their problem was solved.
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
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
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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