hello writing lua script aegisub have problems language. used coding in c++ only(as hobby) , can't figure out many things in lua. error in line 11 of script. message aegisub this: [string "remove_unused_styles.lua"]:11: attempt length of local 'styles' (a nil value)
here relevant link on aegisub forum: http://forum.aegisub.org/viewtopic.php?f=5&t=2944
, here code:
code:script_name = "remove unused styles" --script_description = "displays dialog let's user decide unused styles remove." script_description = "scan , remove unused styles" script_author = "sledgehammer_999" script_version = "1.00" function remove_unused_styles_macro(subtitles, selected_lines, active_line) local styles = 1, #subtitles if subtitles[i].class == "style" styles[#styles + 1].name = subtitles[i].name styles[#styles + 1].index = end end --styles definitions collected --now let's go on dialogue lines , see ones used = 1, #styles k = 1, #subtitles styles[i].used = false if subtitles[k].class == "dialogue" , subtitles[k].style == styles[i].name styles[i].used = true break end end end --at point have marked unused styles --todo: display dialog , let user decide ones remove. don't know how determine optimal size of controls. --remove unused styles. local styles_index --this loop redundant. incorporated above, it's placed here when dialog implemented. = 1, #styles if styles[i].used == false styles_index[#styles_index + 1] = end end --now have unused styles let's remove them , make , undo point subtitles.delete(unpack(styles_index)) aegisub.set_undo_point(script_name) end aegisub.register_macro(script_name, script_description, remove_unused_styles_macro)
try initializing "styles" table:
http://www.lua.org/pil/11.1.htmlcode:local styles = {}
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Lua noob
Ubuntu
Comments
Post a Comment