Lua chatbox

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

Moderator: Plugin Moderators

User avatar
ian`
Supporter
Reactions:
Posts: 110
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#161

Post by ian` »

i got the other fact. if you call the build mode from createDraftDrawer, the draft will be added to the history as a new even if the draft in there before, not replace the last one. @Lobby Sorry to mention you, could you fix this bug?
:bc

User avatar
Lobby
Developer
Reactions:
Posts: 3637
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

Platform

Re: Lua chatbox

#162

Post by Lobby »

Thanks, will fix that :bf
=^._.^= ∫

Jeremiah Stephens
Inhabitant of a Megacity
Reactions:
Posts: 208
Joined: Thu Jan 30, 2020 16:56
Plugins: Show

Platform

Plugin Creator

Re: Lua chatbox

#163

Post by Jeremiah Stephens »

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)
Interactive Lua editor
Run
Check out my TheoTown YouTube videos (and subscribe): https://www.youtube.com/playlist?list=P ... wCvFdgyiTk
Show
Warning: do not tap or click "Show"
Just kidding, join my discord server: http://discord.gg/hA5EVazhCC

User avatar
Lakan Haraya
Metropolitan
Reactions:
Posts: 127
Joined: Thu Mar 28, 2019 9:34
Location: Philippines
Plugins: Show
Version: Beta

Plugin Creator

Platform

Re: Lua chatbox

#164

Post by Lakan Haraya »

I would like to tap the building and then GUI will appear, how can I do that?
"ᜀᜃᜓ ᜀᜅ᜔ ᜁᜌᜓᜅ᜔ ᜑᜇᜌ"
CEO of Haráya Motors

“TheoTown Philippines Council”
“Kapulungan Ng Mga Nagkakaisang Lungsod”

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 671
Joined: Mon Jul 17, 2017 16:16
Location: Philippines
Plugins: Show

Platform

Plugin Creator

Re: Lua chatbox

#165

Post by Hadestia »

Lakan Haraya wrote:
Tue Feb 16, 2021 8:53
I would like to tap the building and then GUI will appear, how can I do that?
Here's my script from my plugin for example

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
Interactive Lua editor
Run
𝕳𝕬𝕯𝕰𝕾𝕿𝕴𝕬
Age of Sail CEO
“TheoTown Philippine Council”
Age of Sail @ TPC discord:https://discord.gg/baMkPTc7nZ

User avatar
ian`
Supporter
Reactions:
Posts: 110
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#166

Post by ian` »

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
Interactive Lua editor
Run
:bc

User avatar
erksmit
Villager
Reactions:
Posts: 11
Joined: Fri Mar 02, 2018 12:39
Plugins: Show

Plugin Creator

Re: Lua chatbox

#167

Post by erksmit »

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?

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5444
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#168

Post by Bearbear76 »

erksmit wrote:
Sat Feb 20, 2021 20: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?
I think using fun variables for simple numbers are good and for more complex stuff use storage.
Just my opinion
I'm probably recompiling my kernel... :o

User avatar
erksmit
Villager
Reactions:
Posts: 11
Joined: Fri Mar 02, 2018 12:39
Plugins: Show

Plugin Creator

Re: Lua chatbox

#169

Post by erksmit »

Bearbear76 wrote:
Sun Feb 21, 2021 5:53
erksmit wrote:
Sat Feb 20, 2021 20: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?
I think using fun variables for simple numbers are good and for more complex stuff use storage.
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 use

User avatar
ian`
Supporter
Reactions:
Posts: 110
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#170

Post by ian` »

why are there so many functions not works correctly now? :bt
buildBuilding can't build RCI buildings, also isBuildingBuildable always returns false when checking RCI buildings.
Draft:isPlugin() can't work properly, but if not Draft:isPlugin() it works fine.
City.createDraftDrawer(d): isSelectable() gets an error on certain drafts.
:bc

User avatar
CommanderABab
AB
Reactions:
Posts: 9587
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#171

Post by CommanderABab »

buildBuilding can't build RCI buildings,

Probably unzoned or incorrect level zone.

User avatar
ian`
Supporter
Reactions:
Posts: 110
Joined: Sat Apr 04, 2020 17:36
Location: Indonesien
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Lua chatbox

#172

Post by ian` »

i have tried it last year and the RCI buildings can be built but without the zoning, and a few months ago it can only be built in zones and those that already have buildings.

EDIT -------
Also Tile.getGroundDraft is not return the draft of the ground. when I use lua wrapper, it says 'LuaRepr'. :bt
:bc

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2137
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Lua chatbox

#173

Post by KINGTUT10101 »

I couldn't get buildBuilding() to work with RCI either.

User avatar
yusuf8a684
Inhabitant of a Planet
Reactions:
Posts: 1553
Joined: Sun Dec 10, 2017 22:09
Location: Turkiye
Plugins: Show

Plugin Creator

Platform

Re: Lua chatbox

#174

Post by yusuf8a684 »

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)
The Internet Addict

don't expect me to finish something

LOL

User avatar
yusuf8a684
Inhabitant of a Planet
Reactions:
Posts: 1553
Joined: Sun Dec 10, 2017 22:09
Location: Turkiye
Plugins: Show

Plugin Creator

Platform

Re: Lua chatbox

#175

Post by yusuf8a684 »

yusuf8a684 wrote:
Tue Jun 01, 2021 17: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)
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...

I have put those notifications in script:nextMonth, yeah they pop up once it becomes next month but then they continue to pop up everyday. I want them to pop up once every month. How can I fix this (because this is annoying to close notifications every TT day)
The Internet Addict

don't expect me to finish something

LOL

dc11
Villager
Reactions:
Posts: 24
Joined: Thu May 13, 2021 2:23

Re: Lua chatbox

#176

Post by dc11 »

Is it possible to automatically rebuild a building that has reached level TTT in Lua to level T?

dc11
Villager
Reactions:
Posts: 24
Joined: Thu May 13, 2021 2:23

Re: Lua chatbox

#177

Post by dc11 »

local x,y

function script:init()
local building = Draft.getDraft('$prm_com02_01')
end

function script:daily (x, y, level)

local count = City.countBuildings(building)
for i, count do
x,y = City.getBuilding(i, building)
Builder.remove(x, y)
end
end


Is this a valid lua?

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 671
Joined: Mon Jul 17, 2017 16:16
Location: Philippines
Plugins: Show

Platform

Plugin Creator

Re: Lua chatbox

#178

Post by Hadestia »

dc11 wrote:
Sun Jul 04, 2021 3:21


Is this a valid lua?
No, you should declare var "building" local outside the function
𝕳𝕬𝕯𝕰𝕾𝕿𝕴𝕬
Age of Sail CEO
“TheoTown Philippine Council”
Age of Sail @ TPC discord:https://discord.gg/baMkPTc7nZ

User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 671
Joined: Mon Jul 17, 2017 16:16
Location: Philippines
Plugins: Show

Platform

Plugin Creator

Re: Lua chatbox

#179

Post by Hadestia »

Can i know how can i include explosion animation when removing buildings using "Builder.remove(x,y)"?
𝕳𝕬𝕯𝕰𝕾𝕿𝕴𝕬
Age of Sail CEO
“TheoTown Philippine Council”
Age of Sail @ TPC discord:https://discord.gg/baMkPTc7nZ

Post Reply Previous topicNext topic

Return to “Lua Scripting”