From 1f9a9062e022c401826155efd3cd45a479d50c15 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 25 Oct 2017 10:51:19 +0200 Subject: Replace many math.floor(x+0.5) calls (or math.floor calls that should be those) by custom atround() function --- advtrains/helpers.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'advtrains/helpers.lua') diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua index 91c0c1c..d7b977e 100644 --- a/advtrains/helpers.lua +++ b/advtrains/helpers.lua @@ -48,6 +48,10 @@ function advtrains.minN(list, expectstart) return n+1 end +function atround(number) + return math.floor(number+0.5) +end + --vertical_transmit: --[[ rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node @@ -80,7 +84,7 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return end --dir2??? local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< - if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then + if atround(cor2.x)==atround(prev.x) and atround(cor2.z)==atround(prev.z) then next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. if midrely2>=1 then next.y=next.y+1 -- cgit v1.2.3