From a270ee9acecafb95970ddf17a857bfee5c494be8 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 5 Aug 2019 13:46:36 +0200 Subject: [PATCH] fix #47 --- mapobject/fancyvend.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mapobject/fancyvend.go b/mapobject/fancyvend.go index 95ffbaa..e211559 100644 --- a/mapobject/fancyvend.go +++ b/mapobject/fancyvend.go @@ -19,11 +19,16 @@ func (this *FancyVend) onMapObject(x, y, z int, block *mapblockparser.MapBlock) parser := luaparser.New() isAdmin := false + isDepositor := false if nodename == "fancy_vend:admin_vendor" || nodename == "fancy_vend:admin_depo" { isAdmin = true } + if nodename == "fancy_vend:player_depo" || nodename == "fancy_vend:admin_depo" { + isDepositor = true + } + payInv := invMap["wanted_item"] giveInv := invMap["given_item"] mainInv := invMap["main"] @@ -88,10 +93,19 @@ func (this *FancyVend) onMapObject(x, y, z int, block *mapblockparser.MapBlock) o.Attributes["owner"] = md["owner"] o.Attributes["type"] = "fancyvend" - o.Attributes["in_item"] = in_item - o.Attributes["in_count"] = strconv.Itoa(in_count) - o.Attributes["out_item"] = out_item - o.Attributes["out_count"] = strconv.Itoa(out_count) + if !isDepositor { + o.Attributes["in_item"] = in_item + o.Attributes["in_count"] = strconv.Itoa(in_count) + o.Attributes["out_item"] = out_item + o.Attributes["out_count"] = strconv.Itoa(out_count) + } else { + // invert in and out + o.Attributes["out_item"] = in_item + o.Attributes["out_count"] = strconv.Itoa(in_count) + o.Attributes["in_item"] = out_item + o.Attributes["in_count"] = strconv.Itoa(out_count) + + } o.Attributes["stock"] = strconv.Itoa(stock_factor) return o