Jump to content

Is it possible?


WiBox

Recommended Posts

I've a script editor script, it will let me edit scripts in-game, but there's something I'm thinking of, is it possible to make like that in a editor( I don't know what to call it so I'll just describe ):

function
local
if
elseif
else
end
while
do
return
break
repeat


Is it possible so I add those things inside a script editor?

I mean those things get written in the blue color...

and the 

math.random

in pink..

Because if it possible, I would add it. Because your eyes can focus on those things and...

Link to comment

In short, yes.

But it depends on the approach. If you're using GUI Memo then no, that won't work. If you're using dx then yes, you can make that work (but that would be unnecessarily difficult).

I personally think that the best approach here would be to use CEF. It would be very easy to make that happen since there are o lot of open source script editors written in JavaScript for the web, just google it and I'm sure you'll find loads.

Link to comment
tbl = {"function", "local", "if", "elseif", "else", "then", "end", "print", "math.random", "math.max"}

local text = 
[[function test()
    local x = 2
    if x == 2 then
        print(x)
        math.random(1, 10)
        math.max(2, 9, 1, 4)
    end
end]]

addEventHandler("onClientRender", root,
function()
	local color = "#FFFFFF"
	for i,v in ipairs(tbl) do
		if text:find(" "..v) or text:find(v.." ") then
			if i > 0 and i <= 7 then
				color = "#0000FF"
			elseif i > 7 then
				color = "#A6E22D"
			end
			text = text:gsub(v, color..v.."#FFFFFF")
		end
	end
	dxDrawText(text, 15, sh/3,_,_,_, 2, "default-bold", "left", "top", false, false, false, true)
end)
Spoiler

dW368QS.png

 

  • Haha 1
  • Confused 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...