Page 8 of 10

Re: Lua chatbox

Posted: 22 Oct 2020, 21:06
by 1Code
Screenshot_20201022-205028_TheoTown.png
Screenshot_20201022-205028_TheoTown.png (31.95 KiB) Viewed 9205 times

Re: Lua chatbox

Posted: 23 Oct 2020, 10:21
by Hadestia
Check Gui Compendium @Jeremiah Stephens

Re: Lua chatbox

Posted: 16 Nov 2020, 11:55
by Hadestia
@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 :)

Re: Lua chatbox

Posted: 17 Nov 2020, 16:23
by Lobby
I'm afraid there's no mechanism to do that.

Re: Lua chatbox

Posted: 18 Nov 2020, 12:24
by ian`
i think you can use string.gmatch and table of the "words" you want to censor.

Re: Lua chatbox

Posted: 23 Nov 2020, 08:46
by Hadestia
ian` wrote: 18 Nov 2020, 12:24 i think you can use string.gmatch and table of the "words" you want to censor.
I used string.gsub and works but can only censor Author name and City name :/

Re: Lua chatbox

Posted: 23 Dec 2020, 16:14
by CERRERA
Can i use lua to make fence animation?

Re: Lua chatbox

Posted: 23 Dec 2020, 23:33
by KINGTUT10101
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.

Re: Lua chatbox

Posted: 24 Dec 2020, 04:25
by Hadestia
KINGTUT10101 wrote: 23 Dec 2020, 23: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.
Here refering from GUI compedium

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
Run

Re: Lua chatbox

Posted: 26 Dec 2020, 00:42
by KINGTUT10101
Gosh darn undocumented functions. Thank you for the help.

Re: Lua chatbox

Posted: 26 Dec 2020, 09:37
by Hadestia
KINGTUT10101 wrote: 26 Dec 2020, 00:42 Gosh darn undocumented functions. Thank you for the help.
i forgot you need first to get the draft of the building by using Draft.getDraft("")

Re: Lua chatbox

Posted: 30 Dec 2020, 02:34
by KINGTUT10101

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
Should 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.

Re: Lua chatbox

Posted: 30 Dec 2020, 14:43
by Hadestia
KINGTUT10101 wrote: 30 Dec 2020, 02:34

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
Should 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.
Ive done this before maybe try to remove the Draft.getDraft()

Re: Lua chatbox

Posted: 30 Dec 2020, 14:45
by Hadestia
:76: one more thing it can't open Draft that was hidden from building tool (hidden:true) unless you gonna move it to hidden categories

Re: Lua chatbox

Posted: 30 Dec 2020, 20:43
by ian`
You forgot to add .select() after draft drawer.

Code: Select all

City.createaDraftDrawer(draft).select()

Re: Lua chatbox

Posted: 31 Dec 2020, 00:48
by KINGTUT10101
That worked! Thanks to you both.

Re: Lua chatbox

Posted: 31 Dec 2020, 01:09
by KINGTUT10101
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?

Re: Lua chatbox

Posted: 31 Dec 2020, 11:40
by ian`
KINGTUT10101 wrote: 31 Dec 2020, 01: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?
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.

To prevent that, you can try this code

Code: Select all

if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then
   City.createDraftDrawer(selectDraft).select()
 end
If that code not work, try to make local var of the history.

Re: Lua chatbox

Posted: 31 Dec 2020, 20:24
by Hadestia
ian` wrote: 31 Dec 2020, 11:40
KINGTUT10101 wrote: 31 Dec 2020, 01: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?
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.

To prevent that, you can try this code

Code: Select all

if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then
   City.createDraftDrawer(selectDraft).select()
 end
If that code not work, try to make local var of the history.
i think these will not work if there is already previous history

Re: Lua chatbox

Posted: 31 Dec 2020, 21:47
by KINGTUT10101
ian` wrote: 31 Dec 2020, 11:40
KINGTUT10101 wrote: 31 Dec 2020, 01: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?
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.

To prevent that, you can try this code

Code: Select all

if City.createDraftDrawer(draft):getHistory()[1] ~= selectId then
   City.createDraftDrawer(selectDraft).select()
 end
If that code not work, try to make local var of the history.
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.