[Rseding91] [0.16.12] Unhandled Error With Mod

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

[Rseding91] [0.16.12] Unhandled Error With Mod

Post 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
  }
}
)
Attachments
factorio-dump-current.dmp
factorio-dump-current.dmp
(434.11 KiB) Downloaded 127 times
factorio-current.log
factorio-current.log
(8.93 KiB) Downloaded 134 times

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Unhandled Error With Mod

Post by Klonan »

Moved to bug reports

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.12] Unhandled Error With Mod

Post by Rseding91 »

Can you please upload the mod that reproduces the crash?
If you want to get ahold of me I'm almost always on Discord.

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: [0.16.12] Unhandled Error With Mod

Post 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
Attachments
mod and logs.zip
mod and logs
(1.11 MiB) Downloaded 135 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.12] Unhandled Error With Mod

Post 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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

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

Post by Muppet9010 »

thanks updated to 0.16.15 and demo mod working as expected in map editor

Post Reply

Return to “Resolved Problems and Bugs”