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: 2123
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

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?

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

Platform

Plugin Creator

Re: City.getView() With Elevated Terrain

#2

Post by Jeremiah Stephens »

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:
Mon Apr 05, 2021 4: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 Jeremiah Stephens on Mon Apr 05, 2021 9:54, edited 1 time in total.
Check out my TheoTown YouTube videos: https://www.youtube.com/playlist?list=P ... wCvFdgyiTk

Code: Select all

c = 0
if TheoTown.addUndoButton != None:
     TheoTown.addUndoButton()
     c += 1
else:
     c -= 1
print(c)
http://discord.gg/hA5EVazhCC

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

Platform

Plugin Creator

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: 2123
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

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: 2123
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

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”