There's no tangiable reward for solving this, but there are certain benifits for those who win:
- The first to correctly solve the problem gets the honor of winning.
- If the problem was some simple thing that anybody should've known, the first person to correctly solve gets the opportunity to give me a slanderous insult!
With that, here's the situation:
An object in a game is supposed to Permanately
'lighten' the area around it when dropped. Darkness is represented by two /area s
/area/world/Dark (Luminosity = 0)
/area/world/Pitchblack (Opacity = 1, Luminosity = 0)
Now for the item's effect programming:
if(src.use == 5)
for(var/area/world/Dark/Ar in range(4,src))
del(Ar)
for(var/area/Pitchblack/Ar in range(4,src))
del(Ar)
viewers(src) << "The orb lights up the area!"
return
Now, this DOES work, but it works a tad too well.
When it drops, every instance of /Dark and /Pitchblack in the entire world disapear, instead of just the instances within the range of 4.
What's the problem?
ID:5582
![]() Nov 19 2005, 1:54 pm
|
|
![]() Nov 19 2005, 2:53 pm
|
|
That's because there's only one instance each of /Dark and /Pitchblack in the entire world; each one has a contents list that defines which turfs it covers. What you want is to remove the turfs in range from the contents of either area.
|
Thanks for the help, but...
I've just got a problem doing that. I tried: for(var/turf/Tu in range(4)) for(var/area/Dark/Ar in world) if(Tu in Ar.contents) Ar.contents -= Tu But that does absolutely nothing. What's my problem? |
Your areas should only have one instance of them (because there's no reason to have multiple instances). So, instead of looping through them, just use locate() to find one. However, to remove a turf from the dark list, you need to add it to a different area. So, for example
var/area/lightedArea/A = locate() for(var/turf/T in range(4)) A += T var/area/somewhatDarkArea/D = locate() for(var/turf/T in range(5) - range(4)) if(istype(T.loc, /area/dark/)) D += T |