Can I detect a building upgrade through Lua?
Moderator: Plugin Moderators
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Can I detect a building upgrade through Lua?
Hello,
I am wondering if you can detect building upgrades through Lua. I know you can detect certain buildings through Draft.getDraft (""), but I would like to know if this would work with upgrades, or if there's another equivalent.
I am wondering if you can detect building upgrades through Lua. I know you can detect certain buildings through Draft.getDraft (""), but I would like to know if this would work with upgrades, or if there's another equivalent.
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: Can I detect a building upgrade through Lua?
I never try that, but there are some functions to detect building upgrades.

Code: Select all
function script:event(x,y,level,event)
if event == Script.EVENT_UPGRADE ...
-- and
Tile.hasBuildingUpgrade(upgradeId,x,y)

- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Can I detect a building upgrade through Lua?
How would I know the location of the building though? It seems like you'd have to know that for this to work. Also, I need to check this for these upgrades on every frame.
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: Can I detect a building upgrade through Lua?
KINGTUT10101 wrote: ↑Thu Jun 25, 2020 2:15How would I know the location of the building though? It seems like you'd have to know that for this to work. Also, I need to check this for these upgrades on every frame.
Im not sure but try this
Code: Select all
local draft = Draft.getDraft("Draft")
function script:event(x,y,level,event)
if event == Script.EVENT_UPGRADE and Tile.getBuildingDraft(x,y) == draft and Tile.hasBuildingUpgrade(x,y) then
-- other stuff
end
.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Plugin creator Doesn't had Cities
- Bearbear76
- Former Bearbear65
- Reactions:
- Posts: 5347
- Joined: Fri Feb 10, 2017 14:53
- Plugins: Show
- Version: Beta
Re: Can I detect a building upgrade through Lua?
The x y values in script:event(x, y, level, event) would be the location of the building.
Just my opinion
- KINGTUT10101
- 1,000,000 inhabitants
- Reactions:
- Posts: 2109
- Joined: Thu Jul 07, 2016 22:50
- Location: 'Merica
- Plugins: Show
- Version: Beta
- Contact:
Re: Can I detect a building upgrade through Lua?
So I don't need to provide values for them?
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
- Bearbear76
- Former Bearbear65
- Reactions:
- Posts: 5347
- Joined: Fri Feb 10, 2017 14:53
- Plugins: Show
- Version: Beta
Re: Can I detect a building upgrade through Lua?
Yes, I wrote something about functions if you want to take a look: viewtopic.php?p=161342#p161342
Just my opinion