I used string.gsub and works but can only censor Author name and City name :/ian` wrote: 18 Nov 2020, 10:24 i think you can use string.gmatch and table of the "words" you want to censor.
Here refering from GUI compediumKINGTUT10101 wrote: 23 Dec 2020, 21:33 I'm sorry for bother you Lua experts lately, but could you tell me how I could get a sidebar button to open the building tool for an item with the ID test.kt101"? I haven't been able to find any documentation or examples of it.
Code: Select all Reset
function script:buildCityGUI() -- Let's append the button to the sidebar line local sidebar = GUI.get('sidebarLine') local size = sidebar:getFirstPart():getChild(2):getWidth() local button = sidebar:getFirstPart():addButton{ width = size, height = size, icon = Icon.OK, frameDefault = Icon.NP_BLUE_BUTTON, frameDown = Icon.NP_BLUE_BUTTON_PRESSED, onClick = function() City.createDraftDrawer("test.kt101")end } end
i forgot you need first to get the draft of the building by using Draft.getDraft("")
Code: Select all
function script:buildCityGUI()
-- Let's append the button to the sidebar line
local sidebar = GUI.get('sidebarLine')
local size = sidebar:getFirstPart():getChild(2):getWidth()
local button = sidebar:getFirstPart():addButton{
width = size,
height = size,
icon = Icon.BIGBIGBIG_MAP,
frameDefault = Icon.NP_BLUE_BUTTON,
frameDown = Icon.NP_BLUE_BUTTON_PRESSED,
onClick = function() City.createDraftDrawer(Draft.getDraft("AreaTool.kt101"))end
}
endIve done this before maybe try to remove the Draft.getDraft()KINGTUT10101 wrote: 30 Dec 2020, 00:34Should this work? I tried it in my project, but it didn't open the building tool after I pressed the button like I was hoping it would.Code: Select all
function script:buildCityGUI() -- Let's append the button to the sidebar line local sidebar = GUI.get('sidebarLine') local size = sidebar:getFirstPart():getChild(2):getWidth() local button = sidebar:getFirstPart():addButton{ width = size, height = size, icon = Icon.BIGBIGBIG_MAP, frameDefault = Icon.NP_BLUE_BUTTON, frameDown = Icon.NP_BLUE_BUTTON_PRESSED, onClick = function() City.createDraftDrawer(Draft.getDraft("AreaTool.kt101"))end } end
Code: Select all
City.createaDraftDrawer(draft).select()It is. I just realized that thing happen on my plugin (the sidebar small button). I thought it no problem because there are not multiple build mode.KINGTUT10101 wrote: 30 Dec 2020, 23:09 I think I found a bug or maybe an oversight in my coding. I am using that function to open the building tool when a sidebar button is pressed, but it creates multiple instances of the item in the recent tab for every time I push the button:
image.png
Oddly enough, these extra instances will disappear after the GUI is refreshed. Is there a way I could fix this?
Code: Select all
if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then
City.createDraftDrawer(selectDraft).select()
endi think these will not work if there is already previous historyian` wrote: 31 Dec 2020, 09:40It is. I just realized that thing happen on my plugin (the sidebar small button). I thought it no problem because there are not multiple build mode.KINGTUT10101 wrote: 30 Dec 2020, 23:09 I think I found a bug or maybe an oversight in my coding. I am using that function to open the building tool when a sidebar button is pressed, but it creates multiple instances of the item in the recent tab for every time I push the button:
image.png
Oddly enough, these extra instances will disappear after the GUI is refreshed. Is there a way I could fix this?
To prevent that, you can try this code
If that code not work, try to make local var of the history.Code: Select all
if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then City.createDraftDrawer(selectDraft).select() end
Unfortunately, it didn't seem to work for me. I did notice something though. One odd quirk about these multiple instances is that getHistory() ignores the extra ones, even if they fill the menu.ian` wrote: 31 Dec 2020, 09:40It is. I just realized that thing happen on my plugin (the sidebar small button). I thought it no problem because there are not multiple build mode.KINGTUT10101 wrote: 30 Dec 2020, 23:09 I think I found a bug or maybe an oversight in my coding. I am using that function to open the building tool when a sidebar button is pressed, but it creates multiple instances of the item in the recent tab for every time I push the button:
image.png
Oddly enough, these extra instances will disappear after the GUI is refreshed. Is there a way I could fix this?
To prevent that, you can try this code
If that code not work, try to make local var of the history.Code: Select all
if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then City.createDraftDrawer(selectDraft).select() end
Code: Select all Reset
GUI.addCanvas { w = 30, h = 30, onDraw = function(self, x, y, w, h, hoverX, hoverY) if hoverX ~= nil or hoverY ~= nil then Drawing.setColor(0, 0, 0) else Drawing.setColor(255, 255, 255) end Drawing.drawRect(x, y, w, h) end } --What do you think? Test this lua code on your PC ((not required but recommended) and reply with a screenshot or video)