Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sp = require(game.ServerScriptService.StudioPlus)
- sp([[
- var x = 5
- function example(parameter) {
- if (parameter < 10) {
- var loops = 0
- while (loops < 10) {
- console.log(loops)
- loops++
- }
- }
- }
- example(5)
- ]]).executeLanguage("javascript")
- --inside the module script where the translation takes place
- function translate(language, code)
- local translations;
- if language == "javascript" or language == "js" then
- translations = {
- ["var"] = "local",
- ["function%s+(%a+)%s*%((.+)%)%s*{"] = "function %1(%2)",
- ["if%s*%((.+)%)%s*{"] = "if %1 then",
- ["while%s*%((.+)%)%s*{"] = "while %1 do",
- ["(%a+)%+%+"] = "%1 = %1 + 1",
- ["}"] = "end",
- ["console%.log"] = "print"
- }
- end
- for pattern, replace in pairs(translations) do
- code = code:gsub(pattern, replace)
- end
- return code
- end
- {
- executeLanguage = function(language)
- --note, object is the passed string in sp(); in this case, the javascript code
- loadstring(translate(language, object))()
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment