Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / modules?!!??! what r they, and i need some math help please

Author
Message
zaltoa
21
Years of Service
User Offline
Joined: 18th Aug 2003
Location: United States
Posted: 25th Aug 2003 08:44
hi ummmmmmmmmmm can ne one tell me what a module is? i dont know and could u give me an example of one, thanks
ok now i need help with some mathimatical crap ok so... i am learning how to do basics for rpg and crap like the attack and defense... i ran into a problem... i did the the attack / defense and multiplied it by 3 so the dmg wouldnt be so low... i got
attack = 50
defense = 100
multiple = 3
dmg = (attack / defense) * multiple
print "damage = "; dmg

and it came out as 0 when it should of did something like 1.5 and rounded it up two... please help i was thinking this might have to do with the real data type instead of just integer...

death metal rules
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 25th Aug 2003 13:28
You're right it is to do with the real data type.
Because all your variables are integers it won't work
eg. 50/100 = 0.5 put this into an integer variable and you get 0
multiply that by anything at all and you get 0

You need to put a # symbol at the end of each variable name to assign it as a real number.

attack# = 50
defense# = 100
mutliple# = 3
dmg#= (attack#/defense#)*multiple#
print "damage = ";dmg#

This will give you 1.5

Nine lives to choose from and I get stuck with this one!
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 25th Aug 2003 16:43
I think he was expecting the compiler to round his number up to the nearest integral value like vb6 does. I didnt know that dbpro didnt do this

"We are getting aggravated"
"Yes, we are"
zaltoa
21
Years of Service
User Offline
Joined: 18th Aug 2003
Location: United States
Posted: 25th Aug 2003 20:24
eys yes yes i thought it would round up to nearest integer not keep it at 1.5, now i need help with this

death metal rules
Mad Mark
21
Years of Service
User Offline
Joined: 25th Aug 2003
Location:
Posted: 25th Aug 2003 22:21
Hi zaltoa, here is a simple function for rounding up. hope this helps
Paul
21
Years of Service
User Offline
Joined: 30th Aug 2003
Location:
Posted: 31st Aug 2003 01:10 Edited at: 31st Aug 2003 04:01
Isn't there a space and speed advantage in keeping to interger variables? So wouldn't manipulating the equation work better. I only got DBpro last week and have been having this problem.

dmg = ((attack*1.0) / defense) * multiple

This works OK. the *1.0 gives a real result.

Or is all this a waste of time. I run intelligent A-Life communities with around 100,000 members so I need all the speed and compacting I can get.

Chaos rules

Login to post a reply

Server time is: 2024-09-20 21:36:59
Your offset time is: 2024-09-20 21:36:59