Here's my script from my plugin for exampleLakan Haraya wrote: 16 Feb 2021, 06:53 I would like to tap the building and then GUI will appear, how can I do that?
Code: Select all Reset
local function BankMainUI() local dialog = GUI.createDialog{ icon = Icon.MONEY, title = 'Theonia Regional Bank', width = 350, height = 230, pause = true } local function addLine(label, height) local line = dialog.content:addLayout{height = height - 5} line:addLabel{text = label, w = 0} return line:addLayout{ x = 0} end local theme = dialog.content:addCanvas{ y = 35,onDraw=function(self,x,y,w,h) Drawing.setAlpha(1) Drawing.setColor(83,133,70) Drawing.drawNinePatch(NinePatch.PANEL,x,y,w,h) Drawing.reset() end} local layout stateUI = 'A' selection(dialog,stateUI,theme,layout) local button1 = addLine("",0) local function addSelectionButton(text, state,frame) button1:addButton{ icon = frame, w = -330, h = 30, frameDefault = NinePatch.TUTORIAL_UNMARK, frameDown = NinePatch.TUTORIAL_MARK, text = text, onClick = function(self)stateUI = state past2 = stateUI end, isPressed = function() return stateUI == state end } end addSelectionButton('Deposit','A',Icon.LOAD_PAYBACK) addSelectionButton('Withdraw', 'B',Icon.LOAN_TAKE) addSelectionButton('Loan', 'C',Icon.LOAN) addSelectionButton('Active Loan', 'AC',Icon.LOAN) addSelectionButton(nil,'info',Icon.HELP) end function script:click(x,y,level) local cv = Tile.isBuildingInConstruction(x,y) if not cv and not City.isSandbox() then BankMainUI() return false end end
Code: Select all Reset
function script:click(x,y) if Tile.isBuildingWorking(x,y) then -- check the building is not in construction and not empty, has power, water, and road connection if needed. yourGUI() -- GUI function return false -- prevent the default dialog appears end end
I think using fun variables for simple numbers are good and for more complex stuff use storage.erksmit wrote: 20 Feb 2021, 18:46 for the plugin im trying to make i need to notify a script in another draft when the user is done doing something, is this possible?
yeah i can pass the variables just fine, but i need to notify script 1 that script 2 is done doing stuff, while i can probably just look at a bools state every frame im wondering if theres something cleaner i can useBearbear76 wrote: 21 Feb 2021, 03:53I think using fun variables for simple numbers are good and for more complex stuff use storage.erksmit wrote: 20 Feb 2021, 18:46 for the plugin im trying to make i need to notify a script in another draft when the user is done doing something, is this possible?
my avatar:
With a little hope to have an answer I also want to talk about notifications. I have made some notifications they are pop-uping at the times when I want but there is one problem I dont really know to fix...yusuf8a684 wrote: 01 Jun 2021, 15:16 Can we use EVENT_CAR_REACHED for a specified car draft or does it takes the information of all cars target reaches?
And also City.spawncar(...) I tried using it but it didnt really did the work. Cars were spawning like how they are in the JSON code and not like the lua. I want them to only spawn in a time cycle (script.nextMonth)
"conductive":trueTurn false, but only after a certain time since I entered the city, for example 5 minutes.
Do this methodkyoshimine1 wrote: 22 Mar 2022, 15:51 I have a question. I was creating a new plugin and it occurred to me that I could use Lua to do something....
Let's say, if I wanted the property"conductive":trueTurn false, but only after a certain time since I entered the city, for example 5 minutes.
Would it be possible to do something like that using Lua?