<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.quasar-rce.com/index.php?action=history&amp;feed=atom&amp;title=Vendetta%2Fbabel%2Fhybrid_example</id>
	<title>Vendetta/babel/hybrid example - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.quasar-rce.com/index.php?action=history&amp;feed=atom&amp;title=Vendetta%2Fbabel%2Fhybrid_example"/>
	<link rel="alternate" type="text/html" href="https://wiki.quasar-rce.com/index.php?title=Vendetta/babel/hybrid_example&amp;action=history"/>
	<updated>2026-04-07T09:32:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.quasar-rce.com/index.php?title=Vendetta/babel/hybrid_example&amp;diff=76&amp;oldid=prev</id>
		<title>Luxen: Created example hybrid + babel plugin</title>
		<link rel="alternate" type="text/html" href="https://wiki.quasar-rce.com/index.php?title=Vendetta/babel/hybrid_example&amp;diff=76&amp;oldid=prev"/>
		<updated>2025-03-14T02:13:52Z</updated>

		<summary type="html">&lt;p&gt;Created example hybrid + babel plugin&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is an example of how a hybrid plugin can be designed to optionally support the Babel library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
[modreg]&lt;br /&gt;
id=bhybridtest&lt;br /&gt;
version=1.0.0&lt;br /&gt;
name=Babel hybrid example &lt;br /&gt;
author=Luxen&lt;br /&gt;
]]--&lt;br /&gt;
&lt;br /&gt;
--public class table to contain entry points to other LME plugins&lt;br /&gt;
local public = {}&lt;br /&gt;
&lt;br /&gt;
--function called to edit functions and strings, and push table to LME&lt;br /&gt;
local update_public&lt;br /&gt;
&lt;br /&gt;
--babel values for plugin&lt;br /&gt;
local babel, lang_key&lt;br /&gt;
local bstr = function(id, val)&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--LME check and execution&lt;br /&gt;
if type(lib) == &amp;quot;table&amp;quot; and lib[0] == &amp;quot;LME&amp;quot; then&lt;br /&gt;
	--register plugin to LME&lt;br /&gt;
	local plugin_path = &amp;quot;plugins/test/&amp;quot;&lt;br /&gt;
	local plugin_main = plugin_path .. &amp;quot;main.lua&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	lib.register(plugin_main)&lt;br /&gt;
	&lt;br /&gt;
	--halt execution if plugin is disabled in LME&lt;br /&gt;
	if not lib.is_ready(plugin_main) then&lt;br /&gt;
		return --the plugin is disabled, stop here&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	--create and/or update plugin&amp;#039;s common content description&lt;br /&gt;
	update_class = function()&lt;br /&gt;
		local class = {&lt;br /&gt;
			CCD1 = true,&lt;br /&gt;
			smart_config = {&lt;br /&gt;
				title = &amp;quot;Babel hybrid example&amp;quot;,&lt;br /&gt;
				action = function() end,&lt;br /&gt;
				description_label = {&lt;br /&gt;
					type = &amp;quot;text&amp;quot;,&lt;br /&gt;
					display = bstr(1, &amp;quot;This is an example hybrid plugin demonstrating Babel usage&amp;quot;),&lt;br /&gt;
				},&lt;br /&gt;
				&amp;quot;description_label&amp;quot;,&lt;br /&gt;
			},&lt;br /&gt;
			description = bstr(1, &amp;quot;This is an example hybrid plugin demonstrating Babel usage&amp;quot;),&lt;br /&gt;
			commands = {},&lt;br /&gt;
			manifest = {&lt;br /&gt;
				&amp;quot;plugins/dummy/main.lua&amp;quot;,&lt;br /&gt;
				&amp;quot;plugins/dummy/lang/en.ini&amp;quot;,&lt;br /&gt;
				&amp;quot;plugins/dummy/lang/es.ini&amp;quot;,&lt;br /&gt;
				&amp;quot;plugins/dummy/lang/fr.ini&amp;quot;,&lt;br /&gt;
				&amp;quot;plugins/dummy/lang/pt.ini&amp;quot;,&lt;br /&gt;
			},&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		for k, v in pairs(class) do&lt;br /&gt;
			public[k] = v&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		lib.set_class(&amp;quot;bhybridtest&amp;quot;, &amp;quot;1.0.0&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	--update Babel functionality now&lt;br /&gt;
	local babel_func = function()&lt;br /&gt;
		babel = lib.get_class(&amp;quot;babel&amp;quot;, &amp;quot;0&amp;quot;)&lt;br /&gt;
		lang_key = babel.register(plugin_path .. &amp;quot;lang/&amp;quot;, {&amp;#039;en&amp;#039;, &amp;#039;es&amp;#039;, &amp;#039;fr&amp;#039;, &amp;#039;pt&amp;#039;})&lt;br /&gt;
		&lt;br /&gt;
		bstr = function(id, val)&lt;br /&gt;
			return babel.fetch(lang_key, id, val)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		public.add_translation = function(path, lang_code)&lt;br /&gt;
			babel.add_new_lang(lang_key, path, lang_code)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		update_public()&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	lib.require({{name = &amp;quot;babel&amp;quot;, version = &amp;quot;0&amp;quot;}}, babel_func)&lt;br /&gt;
	&lt;br /&gt;
	--[[&lt;br /&gt;
		Any LME-specific code here&lt;br /&gt;
	]]--&lt;br /&gt;
	&lt;br /&gt;
	--OR call this at the end of the plugin inside its own LME check&lt;br /&gt;
	lib.set_class(&amp;quot;bhybridtest&amp;quot;, &amp;quot;1.0.0&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Your plugin here&lt;br /&gt;
]]--&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Luxen</name></author>
	</entry>
</feed>