Skip to content

rttr:AddTerrain() for MyMap.lua#1958

Draft
morganchristiansson wants to merge 1 commit into
Return-To-The-Roots:masterfrom
morganchristiansson:map-addterrain
Draft

rttr:AddTerrain() for MyMap.lua#1958
morganchristiansson wants to merge 1 commit into
Return-To-The-Roots:masterfrom
morganchristiansson:map-addterrain

Conversation

@morganchristiansson

@morganchristiansson morganchristiansson commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

It's incredible how quick it is to make a proof of concept PR with AI.
Not tested at all yet.

But if you have some early thoughts - all feedback is welcome.

The idea is to enable map creators to use custom textures, from S2 gamedata or externally provided.
So they could provide zip with:

MyMap.swd
MyMap.lua
MyMap.lbm

MyMap.lua calls rttr.AddTerrain(filename = "MyMap.lbm") with a bunch of parameters to define extra textures.

Changes:

  • Expose rttr:AddTerrain() to MyMap lua in LuaInterfaceGame
  • Disallow harbout bit 0x40
  • Allow 7 bit s2Ids (all except harbour bit)
  • Disallow replacing existing s2Ids (or maybe should be allowed idk)
  • Support <RTTR_MAP> or relative path from MyMap.lua
  • Existing path validations (only current dir and subfolders)

PR is really small really.

Open questions:

  • Some way to embed textures/lua in maps would be nice. Maybe .swz that is a zip file? idk.
  • need to consider API for map creators., rttr:AddTerrain() was added by Flamefire in 2017 so I guess it's feature complete and stable.
  • Support more image formats than lbm/bbm/bmp. maybe add png?
  • 32bit HD textures
  • Also need rttr:AddTerrainEdge()?

Also reason for this PR is to get all pieces on the board while adding s25edit custom texture support. There is no rush at all to review & merge this, it's not ready.
As workaround data/RTTR/gamedata/world/greenland/wasteland/winterland.lua can be edited to support new textures without changes which should work for testing purposes, but is not ideal for distributing maps with custom textures if map creators start doing this.
My enthusiasm for this depends on enthusiasm of map creators to use custom textures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant