When attempting to follow http://www.byond.com/forum/?post=1613721 guide on dealing with immutability/mutability with overlays, a code snippet is utilized to remove overlays and underlays from a mob. While working perfectly well for underlays, the snippet working on overlays bugs out returning an index out of bound error.
Numbered Steps to Reproduce Problem:
1. Code copied and adjusted from linked thread.
2. Successful compile.
3. Utilizing the verb in the game.
Code Snippet (if applicable) to Reproduce Problem:
Overlays_Remove()
set category="Other"
appearanceO = overlays[overlays.len]
appearanceU = underlays[underlays.len]
usr.overlays-= appearanceO
usr.underlays-= appearanceU
Variables appearanceO and U defined before.
Expected Results:
Both overlays and underlays are stored in the appearance vars, then removed and can be rather restored with Overlay Restore.
Overlays_Restore()
set category="Other"
usr.overlays+= appearanceO
usr.underlays+= appearanceU
Actual Results:
Works fine with underlays but overlays return an error:
runtime error: list index out of bounds
proc name: Overlays Remove (/mob/Players/verb/Overlays_Remove)
usr: (src)
src: Test(/mob/Players)
src.loc: CustomTurf (130,190,5) (/turf/CustomTurf)
call stack:
Test(/mob/Players): Overlays Remove()
Does the problem occur:
Every time? Or how often? 100% of the time
In other games? N/A
In other user accounts? Yes
On other computers? Yes
When does the problem NOT occur?
N/A
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
N/A
Workarounds:
None