Page 1 of 1

[Rseding91] [0.16.12] Unhandled Error With Mod

Posted: Sun Dec 31, 2017 11:05 pm
by Muppet9010
I was playing around trying to add a new type of water.
The error message implies you want these reported to help improve error messages.
I'll raise a separate post to see if anyone can advise on how to do this properly.

The game 16.12 errors when starting the map editor.
The offending code I added to a mod lua file to cause the unhandled exception was:

Code: Select all

water_tile_type_names = { "water", "deepwater", "water-green", "deepwater-green",[b] "driedwater"[/b] }

function water_transition_template(to_tiles, normal_res_transition, high_res_transition, options)
  local function make_transition_variation(src_x, src_y, cnt_, line_len_, is_tall)
    return
    {
      picture = normal_res_transition,
      count = cnt_,
      line_length = line_len_,
      x = src_x,
      y = src_y,
      tall = is_tall,
      hr_version=
      {
        picture = high_res_transition,
        count = cnt_,
        line_length = line_len_,
        x = 2 * src_x,
        y = 2 * (src_y or 0),
        tall = is_tall,
        scale = 0.5,
      }
    }
  end

  local t = options.base or {}
  t.to_tiles = to_tiles
  local default_count = options.count or 16
  for k,y in pairs({inner_corner = 0, outer_corner = 288, side = 576, u_transition = 864, o_transition = 1152}) do
    local count = options[k .. "_count"] or default_count
    if count > 0 and type(y) == "number" then
      local line_length = options[k .. "_line_length"] or count
      local is_tall = true
      if (options[k .. "_tall"] == false) then
        is_tall = false
      end
      t[k] = make_transition_variation(0, y, count, line_length, is_tall)
      t[k .. "_background"] = make_transition_variation(544, y, count, line_length, is_tall)
      t[k .. "_mask"] = make_transition_variation(1088, y, count, line_length)
    end
  end

  return t
end

data.raw["tile"]["grass-1"].transitions.water_transition_template = water_transition_template
  (
      water_tile_type_names,
      "__base__/graphics/terrain/water-transitions/grass.png",
      "__base__/graphics/terrain/water-transitions/hr-grass.png",
      {
        o_transition_tall = false,
        u_transition_count = 4,
        o_transition_count = 8,
        base =
        {
          side_weights = { 1, 1, 1, 1,  0.25, 0.25, 1, 1,  1, 1, 0.125, 0.25,  1, 1, 1, 1 }
        }
      }
  )

data:extend(
{
  {
    name = "driedwater",
    type = "tile",
    collision_mask =
    {
      "water-tile",
      "resource-layer",
      "item-layer",
      "player-layer",
      "doodad-layer"
    },
    draw_in_water_layer = true,
    layer = 0,
    variants =
    {
      main =
      {
        {
          picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater1.png",
          count = 8,
          size = 1,
          hr_version = {
            picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater1.png",
            count = 8,
            scale = 0.5,
            size = 1
          }
        },
        {
          picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater2.png",
          count = 8,
          size = 2,
          hr_version = {
            picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater2.png",
            count = 8,
            scale = 0.5,
            size = 2
          }
        },
        {
          picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater4.png",
          count = 6,
          size = 4,
          hr_version = {
            picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater4.png",
            count = 8,
            scale = 0.5,
            size = 4
          }
        }
      },
      inner_corner =
      {
        picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater-inner-corner.png",
        count = 6,
        hr_version = {
          picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater-inner-corner.png",
          count = 6,
          scale = 0.5
        }
      },
      outer_corner =
      {
        picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater-outer-corner.png",
        count = 6,
        hr_version = {
          picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater-outer-corner.png",
          count = 6,
          scale = 0.5
        }
      },
      side =
      {
        picture = "__MuppetWaterUsage__/graphics/driedwater/driedwater-side.png",
        count = 8,
        hr_version = {
          picture = "__MuppetWaterUsage__/graphics/driedwater/hr-driedwater-side.png",
          count = 8,
          scale = 0.5
        }
      }
    },
    allowed_neighbors = { "water" },
    map_color={r=38, g=64, b=73},
    ageing=0.0006
  }
}
)

Re: Unhandled Error With Mod

Posted: Sun Dec 31, 2017 11:31 pm
by Klonan
Moved to bug reports

Re: [0.16.12] Unhandled Error With Mod

Posted: Sun Dec 31, 2017 11:58 pm
by Rseding91
Can you please upload the mod that reproduces the crash?

Re: [0.16.12] Unhandled Error With Mod

Posted: Mon Jan 01, 2018 12:13 am
by Muppet9010
I have added to the mod slightly in terms of another water type so put fresh error logs in as well.

I see the issue when starting the map editor after a few seconds or so. I can just zoom out to cause it to occur. Default new map settings.

This is a very rough play around so please ignore the intentional white images in places.

Offending code is in prototypes\driedwater.lua

Re: [0.16.12] Unhandled Error With Mod

Posted: Mon Jan 01, 2018 12:44 am
by Rseding91
Thanks for the mod. It's now fixed for the next version of 0.16.

There's nothing wrong with your code that I saw - it was an error on our side parsing in the Lua definitions.

Re: [Rseding91] [0.16.12] Unhandled Error With Mod

Posted: Sun Jan 07, 2018 2:35 pm
by Muppet9010
thanks updated to 0.16.15 and demo mod working as expected in map editor