GUI Compendium

The Lua scripting language allows you to give your plugin more advanced features.

Moderator: Plugin Moderators

User avatar
Eiyu
Settler
Reactions:
Posts: 4
Joined: 12 Jan 2021, 00:51

Re: GUI Compendium

#21

Post by Eiyu »

thank’s i used it for this:

Code: Select all

  local function text()
  	local iconFrame=Draft.getDraft('$pickle_kets_icon'):getFrame()
  local dialog = GUI.createDialog{
    icon = iconFrame,   -- Icon of the dialog
    title = 'Ket Options',        -- Title of the dialog
			    text = 'Here are the ket ontions{Other[*send a gift to pickle(50 kets)tiping kets(10)]Geting kets[*Buy 15 kets for 20 theos]seveces[*fire deparment28 coses 30 kets]buying rockets[*get Pmars for 5000 kets*get Trocket for 900 kets*get a shuttle for 1,000,000 kets]}On the text feld enter your command.',          
    width = 300,            
    height = 180,          
    closeable = true,       
    pause = false,           
    onUpdate = function() end,   
    onCancel = function() end,  
    onClose = function() end,
    actions = {
      
      {
        id = '$cmdOk',  
        icon = Icon.PLUS,     
        text = "Done",      
        onClick = function() end,
        golden = false
      }
    }
  }
  
local parent = dialog.controls:getFirstPart()

local textField = parent:addTextField{
  text = 'Enter Command',
  height = 30,
  width = 200
}
textField:setText('')
textField:getChild(1):setColor(255,0,255)
end


function script:buildCityGUI()
	--Debug.toast('In buildCityGUI in Kets.lua')
	--Debug.toast('Hi Charles!')
	local iconFrame=Draft.getDraft('$pickle_kets_icon'):getFrame()
	local budget = GUI.get('cmdBudget')
	local bottomBar = budget:getParent()
	local width = budget:getWidth()
	local height = budget:getHeight()
	local button=bottomBar:getCenterPart():addButton{
		width=width,
		height=height,
		icon=iconFrame,
		text='Ket options',
		golden=true,
		--frameDefault=Icon.NP_BLUE_BUTTON,
		onClick=function(self)
			-- Debug.toast('clicked')
			text()
		end
	}
end
Note from Bearbear76: You can use the code tag for code. It look prettier doesn't it? :)
User avatar
1Code
Inhabitant of a Megacity
Reactions:
Posts: 302
Joined: 30 Jan 2020, 16:56
Location: https://bit.ly/3P5dhnT
Plugins: Showcase Store

Plugin Creator

Platform

Re: GUI Compendium

#22

Post by 1Code »

Lobby wrote: 03 Dec 2020, 23:29 Yeah, you would have to implement your own dialog or try to add a GUI object that covers it and draws something else. An easier option would probably be to use privileged placing features to change look of dialogs in general.
What do you mean about privileged placing features?
User avatar
opschnecke
Settler
Reactions:
Posts: 3
Joined: 12 Oct 2020, 13:14

Plugin Creator

Platform

Re: GUI Compendium

#23

Post by opschnecke »

Can i Use own pictures as for example Button Icons? :lua:
User avatar
Yakka
Inhabitant of a Conurbation
Reactions:
Posts: 413
Joined: 06 Jan 2020, 09:57
Location: Java-indonesia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

#24

Post by Yakka »

I need some help to make an list box because the list content didn't show up on the game.
Screenshot_2021-11-22-09-23-20-279_info.flowersoft.theotown.theotown.jpg

Code: Select all    Reset

local function showitptestdialog() local function createIconPreview(parent, frame) end local dialog = GUI.createDialog{ icon = Icon.PEOPLE_OFFICEWORKER, title = 'Credits', width = 240, height = 300 } local listBox = dialog.content:addListBox{} local listBox = parent:addListBox{ x = 10, y = 10, width = -10, height = -10 } for i = 0, 10 do local entry = listBox:addCanvas{h=30} entry:addLabel{ text = name, x = height + 5, w = -30 }:setFont(Font.SMALL) entry:addButton{ icon = Icon.COPY, x = -30, w = 26, onClick = function() Runtime.setClipboard(name) Debug.toast('Put '..name..' into clipboard') end } local lbl = entry:addLabel{ text = 'Terima Kasih Kepada:', width = -30 } local cmd = entry:addButton{ x = -35, width = 30, icon = Icon.OK, onClick = function() Debug.toast('Clicked on entry '..i) end } end --GUI Example plugin -- Show the menu with the close action closing the provided dialog local function showMenu(dialog) local parent = GUI.get'$menuparent' GUI.createMenu{ source = parent, actions = { {icon = Icon.OK, text = 'A', onClick = function() Debug.toast('yo') end}, {icon = Icon.CANCEL, text = 'B', enabled = false}, {}, {icon = Icon.CLOSE, text = 'Close', onClick = dialog.close} } } end addItems(Icon, Icon.keys, 'Icon', 26, function(item, x, y, w, h) Drawing.drawImage(item, x, y) end) addItems(NinePatch, NinePatch.keys, 'NinePatch', 26, function(item, x, y, w, h) Drawing.drawNinePatch(item, x, y, w, h) end) addItems(Font, Font.keys, 'Font', 26, function(item, x, y, w, h) Drawing.setColor(0, 0, 0) Drawing.drawText('Abc', x+w/2, y+h/2, item, 0.5, 0.5) Drawing.reset() end) end
Interactive Lua editor
Run
User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: GUI Compendium

#25

Post by Lobby »

image.png
I see there are two listboxes created here. So my assumption is the first one is the one seen in your image while the second one will actually be populated with entries.
User avatar
Yakka
Inhabitant of a Conurbation
Reactions:
Posts: 413
Joined: 06 Jan 2020, 09:57
Location: Java-indonesia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

#26

Post by Yakka »

Screenshot_2021-11-22-17-37-22-475_info.flowersoft.theotown.theotown.jpg
Still doesn't show up

Code: Select all    Reset

--Show the test dialong local function showitptestdialog() local function createIconPreview(parent, frame) end local dialog = GUI.createDialog{ icon = Icon.PEOPLE_OFFICEWORKER, title = 'Credits', width = 240, height = 300 } local listBox = dialog.content:addListBox{} local entry = listBox:addCanvas{h=30} entry:addLabel{ text = 'TestTest', x = height + 5, w = -30 }:setFont(Font.SMALL) local lbl = entry:addLabel{ text = 'Terima Kasih Kepada:', width = -30 } local cmd = entry:addButton{ x = -35, width = 30, icon = Icon.OK, onClick = function() Debug.toast('Clicked on entry '..i) end } end --GUI Example plugin -- Show the menu with the close action closing the provided dialog local function showMenu(dialog) local parent = GUI.get'$menuparent' GUI.createMenu{ source = parent, actions = { {icon = Icon.OK, text = 'A', onClick = function() Debug.toast('yo') end}, {icon = Icon.CANCEL, text = 'B', enabled = false}, {}, {icon = Icon.CLOSE, text = 'Close', onClick = dialog.close} } } end --Show the Credits list dialog window local function showcreditsDialog() local dialog = GUI.createDialog{ icon = Icon.PEOPLE_OFFICEWORKER, title = 'Credits', text = [[Credits Kiki012,Kingtut101,Matthew Fillbert,Akunbaru123,Pederont,mdk_813, theotheorich,lobbydivinus,and justanyone Non Forum Member Chris (Discord),and Alan (FTTI) License CC BY ]], height = 250, width =250 } end --Show the info Menu local function showinfoMenu(dialog) local parent = GUI.get'$menuparent' GUI.createMenu{ source = parent, actions = { { icon = Icon.COPY, text = 'Discord', onClick = function() Runtime.setClipboard('https://discord.gg/UEDRUnFbEJ') Debug.toast('Put the Discord invite link into clipboard') end, autoClose = false }, { icon = Icon.COPY, text = 'Whatsapp (indonesian Only)', onClick = function() Runtime.setClipboard('https://chat.whatsapp.com/Bv4EIv7Jvjb8ViXeSJK0WS') Debug.toast('Link Grup Tersimpan di Clipboard') end, autoClose = false }, { icon = Icon.COPY, text = 'Website', onClick = function() Runtime.setClipboard('https://kiki012184.github.io/K012-Theot ... lugin.html') Debug.toast('Put the website link into clipboard') end, autoClose = false } } } end --https://kiki012184.github.io/K012-Theot ... lugin.html -- Show the main dialog window local function showDialog() local dialog dialog = GUI.createDialog{ icon = Icon.INFO, title = 'Plugin Manual', text = [[Welcome to Indonesia Transportation Pack! This plugin add New Content Related to Transportation in Indonesia. You can unlock the road section if your city have enough ranks. Unlocking Train is bit more complicated,you need station headmaster house first,then it time for your decision,either unlocking local made trains,you just need to build an train factory,or imported trains,by building dedicated port,most of Indonesian train are imported. Sadly, some features are limited,And Some Bugged. There Are Patch or addon for this plugin such as normal rail compability,remove roads,and much more,click more info and get the link to my website. if you got a bug or a problem, or have an idea, please post it in comments. to be honest being an plugin creator is hard,especialy managing an huge plugin like this.]], width = 250, height = 400, actions = { { icon = Icon.PEOPLE_OFFICEWORKER, text = 'Credits', onClick = showcreditsDialog, autoClose = false }, { id = '$menuparent', icon = Icon.INFO, text = 'More Info', onClick = function() showinfoMenu(dialog) end, autoClose = false }, { icon = Icon.PEOPLE_OFFICEWORKER, text = 'Test', onClick = showitptestdialog, autoClose = false } } } closeDialog = dialog.close end -- Rebuild dialog after code changes function script:init() if closeDialog then closeDialog() closeDialog = nil showDialog() end end -- Let's cheat a little by closing the tool immediately after it was opened function script:event(_, _, _, event) if event == Script.EVENT_TOOL_ENTER then GUI.get('cmdCloseTool'):click() showDialog() end end
Interactive Lua editor
Run
User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: GUI Compendium

#27

Post by Lobby »

Did you use "strict lua":true in your json? I assume the script crashed, eg. in line 17 height is not defined.
User avatar
Wepf
Inhabitant of a Megacity
Reactions:
Posts: 285
Joined: 14 Oct 2021, 10:19
Location: Your lucid dream
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

#28

Post by Wepf »

I guess it actually a time to put my brain in garbage incerator
User avatar
Yakka
Inhabitant of a Conurbation
Reactions:
Posts: 413
Joined: 06 Jan 2020, 09:57
Location: Java-indonesia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

#29

Post by Yakka »

Is there a way to add translation on custom gui,
I mean i want GUI A text and title translated into English and indonesian.
User avatar
Marvel
Townsman
Reactions:
Posts: 96
Joined: 29 Nov 2020, 08:47
Location: Indonesia
Plugins: Showcase Store
Version: Beta

Re: GUI Compendium

#30

Post by Marvel »

Lobby wrote: 05 Sep 2020, 10:42 <the original post>
Ok So where we need to place the file are iys need json or something like that?
User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

#31

Post by erksmit »

Is there a way to create a panel with a diffrent ninepatch? Currently i am simply using a canvas with onDraw but i was wondering whether panels support it out of the box
User avatar
Guest
Reactions:

Re: GUI Compendium

#32

Post by Guest »

erksmit wrote: 03 Jan 2023, 11:12See above me
It isn't possible
User avatar
Guest
Reactions:

Re: GUI Compendium

#33

Post by Guest »

Kiki012 wrote: 25 Dec 2021, 17:51Click or scroll up
https://doc.theotown.com/modules/TheoTo ... lateInline
User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

#34

Post by erksmit »

Theotronic Arts wrote: 13 Jan 2023, 07:17
erksmit wrote: 03 Jan 2023, 11:12See above me
It isn't possible
Why isn't it possible.
User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

#35

Post by erksmit »

Can i pass a ninepatch to use when creating a panel object? The examples don't include any mention of this.
User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

#36

Post by erksmit »

Chief this is false information that does not work, please test it before giving me an incorrect answer.
20230209161553_1.jpg
As you can see it does not change the background whatsoever, it will still be the default panel.
User avatar
NotPFA
Townsman
Reactions:
Posts: 70
Joined: 28 Jan 2023, 17:34
Plugins: Showcase Store

Plugin Creator

Platform

Re: GUI Compendium

#37

Post by NotPFA »

User avatar
erksmit
Villager
Reactions:
Posts: 23
Joined: 02 Mar 2018, 12:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

#38

Post by erksmit »

its no matter, i will just draw the ninepatch
Post Reply Previous topicNext topic

Return to “Lua Scripting”