godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.7k stars 20.12k forks source link

Internal Script Error! - opcode #0 (report please). #25137

Closed xsellier closed 5 years ago

xsellier commented 5 years ago

Godot version: v2.1.5

OS/device including version:

Issue description:

Steps to reproduce: It is really hard to reproduce. I'm running closed beta for City Game Studio. This function works 99,99% of the time. However it has failed only once.

Minimal reproduction project: I can't give one, but I can give you the piece of code where it happend

func compute_note_from_platform(absolute_note, total_capacities_points, platform_id, size):
  var platform = platform_model.get_platform_by_id(platform_id)
  var games_by_platform = platform_model.get_games_per_platform_by_id(platform_id)
  var platform_generation_requirement = size.platform_generation_requirement
  var platform_generation = platform.generation
  var note_ratio = max(1.0, platform_generation * platform_generation_requirement * 100)

  for game_id in games_by_platform:
    var game = game_model.get_game_by_id(game_id)
    var game_size = game_model.get_game_size_by_name(game.size)

    # Compare game of the same size
    if game_size.label == size.label and \
       game.has('total_capacities_points'):
      note_ratio = max(game.total_capacities_points, note_ratio)

  logger.debug('Note ratio: %s, total: %s' % [note_ratio, total_capacities_points])
  note_ratio = clamp(total_capacities_points / note_ratio * 1.0, 0.65, 1.05)

  return absolute_note * note_ratio
xsellier commented 5 years ago

Found out what was the root cause.

Im using godot to localize dialog in my game. Since I have 11 differents languages, I don't have time to test them all. So, I do few tests and if everything is ok, it goes to production. However When a translation does not contain the right amount of %s to format (using '%s' [ myvar ]`), then I get an opcode #0.

I wanted to explain it here, because I think it would be great if we can improve this error code a bit, for example in order to have a proper idea of what is going on here