City.getView() With Elevated Terrain

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

City.getView() With Elevated Terrain

#1

Post by KINGTUT10101 »

I noticed that City.getView() does not account for tiles on elevated terrain. It will only see tiles on level zero. Is there any way around this limitation?
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: City.getView() With Elevated Terrain

#2

Post by 1Code »

Code: Select all    Reset

function script:draw() local x, y = City.getView() if Tile.isValid(x, y) then x = x + Tile.getTerrainHeight (x, y) y = y - Tile.getTerrainHeight (x, y) end Drawing.setTile(x, y) Drawing.drawTileFrame(Icon.TOOLMARK + 16 + 1) end
Interactive Lua editor
Run

KINGTUT10101 wrote: 05 Apr 2021, 04:51 IS there a way to get this working with script:update?

Code: Select all    Reset

function script:update() local x, y, scale = City.getView() if Tile.isValid(x, y) then x = x + Tile.getTerrainHeight (x, y) y = y - Tile.getTerrainHeight (x, y) end Drawing.drawText('X:'..x..',Y:'..y..',S:'..s) end
Interactive Lua editor
Run
Last edited by 1Code on 05 Apr 2021, 09:54, edited 1 time in total.
User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: City.getView() With Elevated Terrain

#3

Post by KINGTUT10101 »

I'll try this out. Thank you for the help. I must not have seen that command when I searched through the Lua Docs a few months ago.
User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: City.getView() With Elevated Terrain

#4

Post by KINGTUT10101 »

IS there a way to get this working with script:update?
User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: City.getView() With Elevated Terrain

#5

Post by KINGTUT10101 »

Thank you for trying to help again. However, I'm not sure if this is the right approach. Stuff like this can happen:
image.png
Do you have any ideas for how we could overcome this issue?
Post Reply Previous topicNext topic

Return to “Plug-In Discussion”