I was trying to make a simple LUA script for controlling the fps limit without needing to open the console, but when i call interface.removeComponent, it creates the component (a button) instead of removing it (i had a button for enabling other buttons and a button for removing them, both behaved in the same way).
Here is the code, if you need:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local fpsp = Button:new(0,20,100,20,"FPS+");
local fpsl = Button:new(0,40,100,20,"FPS-");
local fpsi = Button:new(0,120,100,20,"Type FPS");
local r = Button:new(150,20,200,20,"Remove buttons from screen");
local enable = Button:new(0,60,100,20,"Add buttons to the screen");
interface.addComponent(enable);
interface.addComponent(r);
local fps=60;
function up()
graphics.drawText(0,100,"Fps limit: "..fps);
end
fpsp:action(
function()
fps=fps+1;
tpt.setfpscap(fps);
end
);
fpsl:action(
function()
fps=fps-1;
tpt.setfpscap(fps);
end
);
fpsi:action(
function()
inp=tpt.input("Fps limit:","Please type the new fps limit");
fps=tonumber(inp);
tpt.setfpscap(tonumber(inp));
end
)
enable:action(
function()
tpt.register_step(up);
interface.addComponent(fpsp);
interface.addComponent(fpsi);
interface.addComponent(fpsl);
enable:enabled(false);
end
)
r:action(
function()
interface.removeComponent(fpsp);
interface.removeComponent(fpsl);
interface.removeComponent(fpsi);
interface.removeComponent(enable);
interface.removeComponent(r);
tpt.unregister_step(up);
tpt.message_box("FPS mod:","Buttons removed.");
end
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The mod isn't that good... I created it just for not needing to open the console everytime i need to set a different limit for FPS.
Thanks for reading and (possibly) helping!
Post scriptum: sorry for bad english... it's not my mother language.
What bad english?
fpsp:visible(false)
fpsl:visible(false)
fpsi:visible(false)
enable:visible(false)
r:visible(false)
Thank you very much!