ID:2570382
 
Not a bug
BYOND Version:513.1517
Operating System:Windows 8 Pro 64-bit
Web Browser:Chrome 81.0.4044.129
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
Turning a direction of 0 produces weird results.

world.log << turn(0, 90)
world.log << turn(0, 180)
world.log << turn(0, 270)
world.log << turn(0, 360)
world.log << turn(0, 45)

produces
1
4
1
2
8

Numbered Steps to Reproduce Problem:
1. do the above

Code Snippet (if applicable) to Reproduce Problem:
world.log << turn(0, 90)
world.log << turn(0, 180)
world.log << turn(0, 270)
world.log << turn(0, 360)
world.log << turn(0, 45)


and it gets worse, I tried it again because I was confused how it got to those results as I saw another result and I think it's just.. randomizing part of it??

kevinz000Today at 6:20 AM
@MoMMIv8ƒ0ƒ
for(var/i in 1 to 30)
world.log << turn(0, 180)
MoMMIv8ƒ0ƒ
BOT
Today at 6:20 AM
Compiler Output
DM compiler version 513.1517
loading code.dm
saving code.dmb
code.dm.dmb - 0 errors, 0 warnings (5/12/20 1:20 pm)
Total time: 0:00
Execution Output
Tue May 12 13:20:56 2020
World opened on network port 49067.
Welcome BYOND! (5.0 Beta Version 513.1517)
5
6
1
10
9
2
6
6
10
10
8
4
10
6
6
4
1
10
2
6
1
2
2
6
2
6
10
4
1
4
The BYOND hub reports that port 49067 is not reachable.


Expected Results:
I dunno, maybe 0 I guess? Doesn't make too much sense to turn a 0 dir.

Actual Results:
2
8
2
1
4

Does the problem occur:
Every time? Or how often? Always
In other games? Not tested
In other user accounts? Not tested
On other computers? The above output was done with a DM eval bot on discord, but I'm very sure this will work if I did it on local too considering a live server broke from it.

When does the problem NOT occur?
Never


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.)
Not sure

Workarounds:
Don't use turn() on 0 because why are you doing that


Lummox JR resolved issue (Not a bug)
This is intended behavior. When dir==0, the result is random.

[edit]
I see this behavior, while intentional, was not documented. The reference will be corrected in 513.1523.
Does the intended random behaviour also apply to "invalid" dirs like 3 (NORTH|SOUTH) and 12 (EAST|WEST)? They appear to exhibit the same behaviour as 0, as do all other values that contain them (i.e. 3, 7, 11-15)
In response to GinjaNinja32
Yes. It also applies to UP and DOWN.