## Can I detect a building upgrade through Lua?

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2112
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.

ian
Supporter
Reactions:
Posts: 102
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)
-- and
Tile.hasBuildingUpgrade(upgradeId,x,y)

KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2112
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.

rjroldan1
Inhabitant of a Megalopolis
Reactions:
Posts: 653
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:15
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.

Im not sure but try this

Code: Select all

local draft = Draft.getDraft("Draft")

function script:event(x,y,level,event)

-- other stuff

end`

.╔═╗─────────────╔╗────────
║╬║─╔╗╔╦╗╔═╗╔╗─╔╝║╔═╗─╔═╦╗
║╗╣─╠╣║╔╝║╬║║╚╗║╬║║╬╚╗║║║║
╚╩╝╔╝║╚╝─╚═╝╚═╝╚═╝╚══╝╚╩═╝
───╚═╝────────────────────
T.P.C.
Theotown Philippine Corporation

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: 2112
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?

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?

KINGTUT10101 wrote:
Thu Jun 25, 2020 16:20
So I don't need to provide values for them?
Yes, I wrote something about functions if you want to take a look: viewtopic.php?p=161342#p161342
Just my opinion