Hello BYOND community. I've had an account for BYOND throughout the course of 2-3 years and have spent my time playing a multitude of games. Very recently, however, I have felt the impulse to begin coding and to create my very own BYOND game. I have read and understood the guide all the way up to Chapter 6, Procs. At this point, I have begun to think about several specific situations and have questions about several of them
For the first, consider this piece of code from the guide.
mob
var/life = 100
proc/HurtMe(D)
life = life - D
if(life < 0)
view() << "[src] dies!"
del src
Now add a Global Variable.
var/global/Strength/x
value = 10
mob
var/life = 100
proc/HurtMe(D)
life = life - D
if(life < 0)
view() << "[src] dies!"
del src
In the proc HurtMe(D) I'd like to replace D with an inequality such as .01x < D <.06x (.01x and .06x as % of X)so that the level of damage would be in between the those two % of whatever the Strength may be. Whenever I put it in as an inequality, as such, however, I get the error report :
....dm:7:error: x: missing comma ',' or right-paren ')'
....dm:7:error: No such node: .1
....dm:7:error: x: expected end of statement
....dm:7:error: ): expected }
....dm:5:error: location of top-most unmatched {
How do I revise such a code to work to my liking? On top of that, what if I wanted to write the inequalities less-than or equal and greater then or equal to? How would I depict the two of them? I'm still a beginner at coding, so please don't think of me as an idiot. I'm not currently working on a project, but when I do, it will probably involve bits of code similar to this.
ID:154821
Dec 9 2011, 5:57 pm (Edited on Dec 9 2011, 6:09 pm)
|
|
You have to put 0.1 rather than .1.
You're defining datums incorrectly. (Strength/whatnot) |
In response to Saucepan Man
|
|
This explained a great deal to me and I think I can get it from here. Thanks.
|
0.1 multiplied by less than D might mean?
I'm going to try and continue without the knowledge though...
I think you should be able to define the max and min percentage of damage based on D by doing something like
Also, you can use DM in < and > signs to create code boxes (as above)