City.getView() With Elevated Terrain
Moderator: Plugin Moderators
- 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
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?
- 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
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
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
Last edited by 1Code on 05 Apr 2021, 09:54, edited 1 time in total.
- 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
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.
- 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
IS there a way to get this working with script:update?
- 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
Thank you for trying to help again. However, I'm not sure if this is the right approach. Stuff like this can happen:
Do you have any ideas for how we could overcome this issue?