area
area1
icon='turf.dmi'
icon_state="blank"
Entered(mob/M)
if(istype(M))
var/pick=rand(1,4)
if(pick==1)
src<<"Monster 1 attacks!"
if(pick==2||3)
src<<"Common monster 2 attacks!"
if(pick==4)
src<<"Monster 3 attacks!"
Problem description: I was just playing around with this to see if I could make it so random monsters come up. The text lines are just there for placeholders. What isn't working is that the text doesn't come up on the map. Because of this, the procs I'm working on won't work as well. What is currently wrong with this? By the way, does area need an icon for it or is it just there? Thanks.
- You're displaying the text to "src". In this context, "src" is the area, and displaying text to an area won't accomplish much. :P You would want to display text to M, in this case
- The code: if(pick==2||3) won't do what you seem. What the compiler will interpret is to run the code indented if the value of pick is 2, or if 3 is a true value. Well, since 3 is always a true value, that block of code will always occur. The correct way to compare pick for both 2 and 3 is to do two separate equality expressions: if(pick==2||pick==3). In your situation, you can easily use a switch statement to compare one value for many. Look up switch in the DM Reference for more information about it
Therefore, your code may look something like this: