Отладка встроенного Lua

Вы можете использовать разборчивое понимание, чтобы сопоставить списки в trucks_dict с элементами в items_dict. Списки должны быть преобразованы в кортежи, чтобы их можно было хешировать как ключи:

{tuple(trucks_dict[k]): [items_dict[i] for i in l] for k, l in packed_items.items()}

Возвращает:

{(9.5, 5.5, 5.5): [[4.6, 4.3, 4.3], [8.75, 5.6, 6.6]],
 (13.0, 5.5, 7.0): [[6.0, 5.6, 9.0]],
 (16.0, 6.0, 7.0): [[4.6, 4.3, 4.3]]}
28
задан deft_code 18 February 2010 в 16:26
поделиться

4 ответа

There are several tools floating around that can do at least parts of what you want. I have seen references to a VS plugin, there is a SciTE debugger extension in Lua for Windows, and there is the Kepler project's RemDebug, as well as their LuaEclipse.

RemDebug may be on the track of what you need, as it was built to allow for debugging CGI scripts written in Lua. It does require access to the LuaSocket module to provide a communications channel between the target script and a controller as well as a couple of other modules.

A bigger issue might be the ability to load arbitrary modules from within whatever sandbox the game engine has put around your scripts. If you have some control over the engine, then that won't be as big an issue.

This isn't currently possible for developers of Adobe Lightroom plugins, for example, because Lightroom does not expose require inside the plugin's sandbox.

A surprise to me has been how rarely I have felt a need for a debugger when working with Lua. I've built several small applications in it for various projects and have been surprised at how well a combination of complete stack backtraces and the occasional print call works to locate the bugs that require "strict" didn't prevent in the first place.

10
ответ дан 28 November 2019 в 03:51
поделиться

Я не понимаю, как должен вызываться DebuggerBreak, поскольку он специфичен для .NET. Я бы предположил, что это работает только с разветвленным Lua, нацеленным на CLR.

Если вы используете стандартный Lua, у вас есть некоторые рудиментарные средства отладки через вызов функции lua debug.debug (). Это выбросит Lua в вашу консоль, поэтому, если вы запускаете lua из консоли, вы должны иметь возможность интерактивно вводить команды lua для проверки вашего текущего состояния. debug.debug () не поместит вас в текущий фрейм стека, поэтому вы должны использовать debug.getlocal () для чтения значений ваших переменных.

Я сам еще не пробовал, но на самом деле я этого не делаю думаю, что создание собственной работающей консоли отладки - это большая работа. Помните, что Lua не такой сложный язык, как C ++, поэтому сделать это намного проще, чем создать настоящий отладчик C ++, такой как, скажем, gdb.

Я думаю, что есть много людей, которые уже делали подобные вещи, чей код вы можете посмотреть в. Здесь - отладчик CLI, написанный только на lua. Всего один файл Луа. Не должно быть трудно использовать и модифицировать для ваших нужд.

2
ответ дан 28 November 2019 в 03:51
поделиться

If you are using windows and VS - Can you use the trick we use?

Copy the lua code in a file. Then in the lua code make a call to the Debugger api (in C++ this is DebuggerBreak() I think - see here). then when the lua code executes the debugger will fire up and you should be able to specify the file. Then debug as normal?

0
ответ дан 28 November 2019 в 03:51
поделиться

Как насчет Decoda ?? есть видео, в котором объясняется, как его использовать, и он чертовски хорошо работает для встроенного источника lua. (я счастливый покупатель). и это довольно дешево.

6
ответ дан 28 November 2019 в 03:51
поделиться
Другие вопросы по тегам:

Похожие вопросы: