Ingame the script editor

How to make an imgame script editor (for a game im making)

This is a big example what of i want to achieve (kinda similar to loadstring)

local functionsexecuted = {}
function Copy(f)

--- output: {["Parameters"] = {"hey"} ["Name"] = "Copy",  ["Position"] = {["startingpos"] = 1, ["endingpos"] = 4,  ["TrueEndPos"] = 7}}

and for the functions to work ill just make a loops through executedfunctions and it’ll sent the parameters to the actual function, i just dont know how i could make a table into this (“hey”, {}) from this {“hey”, {}}


bumper bumping this up cuz im stuck

id personally say, I don’t really have a solution (atm) but please be careful as people could RUIN the game with this if you don’t add enough protection

edit: maybe loop through the lines and see if the syntax matches and if it does then run the func, heres an example

local functions = {}
functions['Copy'] = function(f)

for line in text_or_script do
     --something here, dont know yet
     --maybe a for loop that checks if the line contains one of the func's?
1 Like

No actually the game is single player and adding 1 thing ill be making a whitelist to the functiosn they use (they’re controlling a localscript) and other than that no they dont have a single access to anything else but to add 1 thing thats funny the game is suppossed to be chaotic cuz they can make their own programs-websites-and everything but its protected under roblox text filtering and roblox decals

1 Like

ye i can do that but the problem what about the parameters of the functions?

i wouldn’t know

but this seems like making a whole new programming language.

heres something i saw: Create your own programming language with P+!…Sort of

1 Like

thats rlly interesting imma look into it

1 Like

i’ve looked into it for a half an hour now and i still dont get nothing

bumping this up oooooo fun fact: im fat jk

1 Like

Creating a programming language can be tricky. Why do you need this data? Can it be done with tools already provided by roblox? Is there a community resource that handles it for you?

I’m assuming the above are all no. This can be kind of complex, you’ll need to look into how programming languages (specifically interpreted ones) are read and maybe executed depending on your scope. There are a few steps and they can be a bit tricky to understand and it will take a lot of work and a fair deal of research probably. This might be a good, albeit long and potentially over scoped source

1 Like

May i understand why this link is useful? i want this data to make an ingame script editor but like i provide all the functions and the things

That link basically teaches you how to make an interpreted language. It sounds like you won’t need all the steps (as you said you’re only building an editor) but some of the earlier steps you will likely need so your editor can understand lua. Honestly, the link might be way more comprehensive than you actually need especially since you are providing everything.

The actual steps you need to take can vary greatly though for a lot of reasons. You could take a scratch like approach in which case almost nothing in that link will be super relevant, but if you are taking a text approach it can walk you through having the computer understand the code.

Additionally libraries can take some of these steps away from you, but this source might be helpful if you don’t understand what the libraries are actually doing.

its not rlly a scripter editor and its rlly simple it doesnt need the lua functions

what can i even use this for sorry? and is this for ingame or what but 1 thing im afraid of this isnt an actual script EDITOR its a custom script maker or some sort

So it’s just a subset where you are calling functions and passing in data?

yea thats rlly simple bascially i put the functiosn the player can call but they call it by typing the name of them and the arguements - how would i go about making this? and the arguments would undersand variables and tables and strings most importantly? (IM GONNA SHART IF U KEEP REPLYING THEN UNREPLIYING :sob::sob::sob::cry:)

Alright, so there are a few things you need to do then.

First is functionNames. This will be easiest if you add every valid function to a list by hand (otherwise you’ll need a more robust implementation anyways to generate them from your source code)

Now when trying to understand the string as a segment of code, you need to be able to split it into individual components with meaning. This is called tokenizing. Things like function names, strings, parenthesis and commas and operators and stuff. A very simple example that technically handles a basic subset of running functions is below, but not feature complete. (it doesn’t handle math operators or some more complex stuff).

Tokenizer example

Note I generated this with GPT, but it has been tested and works for it’s subset that it handles

function tokenize(code)
    local tokens = {}
    local token = ""
    local in_string = false
    local escape = false
    local string_char = ""

    for i = 1, #code do
        local char = code:sub(i, i)
        if char == "\\" and in_string and not escape then
            escape = true
            token = token .. char
        elseif (char == "'" or char == '"') and not escape then
            if in_string and char == string_char then
                in_string = false
                token = token .. char
                table.insert(tokens, token:match("^%s*(.-)%s*$"))  -- Insert token and trim whitespace
                token = ""
            elseif not in_string then
                in_string = true
                string_char = char
                token = token .. char
        elseif not in_string and (char == '(' or char == ')' or char == ',') then
            if #token > 0 then
                table.insert(tokens, token:match("^%s*(.-)%s*$"))  -- Trim whitespace and add token
                token = ""
            table.insert(tokens, char)
            if escape then escape = false end
            token = token .. char

    if #token > 0 then
        table.insert(tokens, token:match("^%s*(.-)%s*$"))  -- Trim whitespace from the last token

    return tokens

-- Example usage
local code = "func('arg1', 'arg2')"
local parsed_tokens = tokenize(code)
for _, token in ipairs(parsed_tokens) do
    print("'" .. token .. "'")  -- Print tokens with quotes to show trimmed whitespace

This next step is somewhat optional and somewhat not. You need to generate an Abstract Syntax Tree. This basically is more information about what every token is (like is it a function name, a string?) and it also includes scope so you can tell what order the stuff runs in. This isn’t technically entirely necessary, but the barebones of the concept is. You need to be able to have it run functions in the correct order passing the correct types. An AST is practically just precalculating that data so you don’t have to do extensive parsing for every line of code you try to run.

I would go into a bit more detail about AST, but that link I sent about interpreters probably does already and I ran out of time.

Basically if libraries exist that handle these things, you really should be looking for them. It’s very likely some or all of this is handled by something somewhere, but you could build it yourself too.

1 Like

oooooo i really like that so bascially this is like setting an environment for everything and telling to the script hey this is a string hey this is a function

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.