New(client/c)
src.Bombs = rand(1,10)
for(/Minefeild/m in oview(0))
if(src.Bombs == 10)
new /turf/Mine/
del src
Code\Turf.dm:35:error:/Minefeild/m:undefined type path
Oh how I hate for statements.
ID:168740
![]() Sep 2 2005, 2:36 pm
|
|
I hate for, the statement never works for me.
New(client/c) Code\Turf.dm:35:error:/Minefeild/m:undefined type path Oh how I hate for statements. |
For loops through a list. What you're looking for is an object, not a path. What you want is this:
for(var/Minefield/m in oview(0)) /Minefield/m is a path, like Minefield m name = "an M-type minefield" ...which is obviously not what you wanted. var/Minefield/m is an object, "m" As an additional note, your "src" references are unneeded there. "src" is assumed if you leave the reference out. However, if it helps you understand your code better, I don't think there's any harm in being specific. If you have difficulty with for() statements in the future, here's a quick workaround: for(i in oview(0)) // or for(i in any_list) if(istype(i,/Minefield)) //do the rest for(i in list) will usually work. Good luck and have fun with your explosives. |
I say scrap that existing thing, since you can do it much better.
A nice way to do it is to create a turf called /turf/minefield. When it's created, a 1 out of 10 chance there'll be a mine in there. That's what you tried to do. turf Creating a turf on top of another turf automatically deletes the bottom turf. ~~> Dragon Lord |
How do you set the name of a turf, without changing the actual name... like the name you see when your mouse is over it?
|
proc/Surronding() How about that... if(src.name1 == "Minefeild") O.o Help? |
Ol' Yeller wrote:
icon_state=surrounding?(surrounding):"blank" You can't set icon_state to a numerical value. You have to use "[surrounding]" there instead. Lummox JR |
Strawgate wrote:
> proc/Surronding() How about that... > if(src.name1 == "Minefeild") O.o Help? As for your loop, no. You are looking for a turf of type /turf/Mine in oview(1,src), but your code suggests that the loop takes into account all turfs in oview(1,src) with Mine as the reference var. proc/Surrounding() Although things like 'src.Surrounding' could simply be shortened to 'Surrounding', and '+= 1' could be shortened to '++', so it might look like: proc/Surrounding() As for the second piece of code...it makes no sense to me. You just randomly threw it in there. If src.Surrounding is always going to be a value of 1-6 - You could simply say that src.icon_state = "[src.Surrounding]" If src.Surrounding will have values 0-6 (0 corresponding to the else clause) - You could change the blank icon_state name to 0, then use src.icon_state = "[src.Surrounding]" You could, of course, throw in checks to make sure that they always have certain values: if(!isnum(Surrounding)||Surrounding>6||Surrounding<1) If you do need to separately check your values, however, don't use back-to-back if statements. Each if statement must be processed. On the other hand, a switch statement is only processed once: switch(Surrounding) Hope that helps, some. Hiead |
You need to define /Minefield/m. Assuming you defined the datum /Minefield, just add <code>var</code>. I can't really do much since you never specified whether it was a turf/obj/mob/area. I'll assume it's the pathtype of an obj.
~~> Dragon Lord