- Screenshot_20201022-205028_TheoTown.png (31.95 KiB) Viewed 1089 times
Lua chatbox
Moderator: Plugin Moderators
-
- Inhabitant of a Megacity
- Reactions:
- Posts: 151
- Joined: Thu Jan 30, 2020 16:56
- Plugins: Show
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
Check Gui Compendium @Jeremiah Stephens
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
@Lobby is there any Runtime modules that detects user inputs in all Textfields?
im making a text sensor that will censored all inappropriate words that the user used, this will be nice addon for the game if you want too
im making a text sensor that will censored all inappropriate words that the user used, this will be nice addon for the game if you want too

.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
I used string.gsub and works but can only censor Author name and City name :/
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- DESOLAN
- Villager
- Reactions:
- Posts: 22
- Joined: Sat Jan 25, 2020 6:19
- Location: Philippines
- Plugins: Show
- Version: Beta
Re: Lua chatbox
Can i use lua to make fence animation?
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
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.
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
Here refering from GUI compediumKINGTUT10101 wrote: ↑Wed Dec 23, 2020 23:33I'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
Interactive Lua editor
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
Gosh darn undocumented functions. Thank you for the help.
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
i forgot you need first to get the draft of the building by using Draft.getDraft("")KINGTUT10101 wrote: ↑Sat Dec 26, 2020 0:42Gosh darn undocumented functions. Thank you for the help.
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
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
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
Ive done this before maybe try to remove the Draft.getDraft()KINGTUT10101 wrote: ↑Wed Dec 30, 2020 2: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
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox

.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- ian`
- Supporter
- Reactions:
- Posts: 99
- Joined: Sat Apr 04, 2020 17:36
- Location: Indonesien
- Plugins: Show
- Version: Beta
Re: Lua chatbox
You forgot to add .select() after draft drawer.
Code: Select all
City.createaDraftDrawer(draft).select()

- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
That worked! Thanks to you both.
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
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:
Oddly enough, these extra instances will disappear after the GUI is refreshed. Is there a way I could fix this?All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
- ian`
- Supporter
- Reactions:
- Posts: 99
- Joined: Sat Apr 04, 2020 17:36
- Location: Indonesien
- Plugins: Show
- Version: Beta
Re: Lua chatbox
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: ↑Thu Dec 31, 2020 1:09I 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
Code: Select all
if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then
City.createDraftDrawer(selectDraft).select()
end

- rjroldan1
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 647
- Joined: Mon Jul 17, 2017 16:16
- Location: Philippines
- Plugins: Show
- Contact:
Re: Lua chatbox
i think these will not work if there is already previous historyian` wrote: ↑Thu Dec 31, 2020 11: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: ↑Thu Dec 31, 2020 1:09I 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
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Lua chatbox
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: ↑Thu Dec 31, 2020 11: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: ↑Thu Dec 31, 2020 1:09I 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
All of my plug-ins, maps and more:
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101
https://sites.google.com/view/retrocity ... authuser=0
YouTube channel:
https://youtube.com/c/kingtut-101