Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

How to use remap function in Lua?

A topic by bearknuckles created Jun 07, 2018 Views: 1,384 Replies: 3
Viewing posts 1 to 3

I've been working on a game, and wanted a way to hide rooms you haven't visited. After some messing around I came across the remap ability of the the map() function. It sounds like it could do this, but I can't figure out how it works. I've checked out the demo cart on it but it's in moonscript. I read the wiki page but it's pretty vague about the remap part. Will this do what I want, and does anyone know how to use this feature with Lua?

Developer

`Remap` is just a callback which is called for every tile on map rendering stage and you can change tile index in the runtime.

Here is simple demo https://tic.computer/play?cart=9 how it works

(1 edit)

okay... I've used Love 2d. They use callbacks a lot so I get how that works. 

That is the demo is looked at but I'm not familiar with moonscript,  so I'm still a bit confused on how to actually feed the remap function data and such. Maybe something like this?

map(0,0,30,17,0,0,-1,remap(tile) 

   If tile == 1 and btn(4) then tile=2)

If map is drawing a 1 tile and the player presses z then change it to a 2 tile.

Is this right?

Remap function takes parameters tile (id), x, y. Optionally returns tile, flip, rotate (as used in spr)