Discord
Login
Community
DARK THEME

How to check if map.

How do you check if the map is a certain map.

example:

if map = "random_map" then player.x += 3

  mymap = maps["map1"]
  player = object
    x = 0
  end
  if mymap.name == "map1" then  player.x += 3 end
  if mymap.name == "map2" then  player.x -= 3 end
  print( player.x )

You can implement this through a variable and already monitor its state, here is an example:

init = function()
  mapsList = ["map", "map2", "map3"]
  n = random.nextInt(mapsList.length)
  player = object
    x = 0
    y = 0
  end
end

update = function()
  if n == 0 then player.x += 1
  elsif n == 1 then player.x += 2
  elsif n == 2 then player.x += 3
  end
end

draw = function()
  screen.clear("rgb(113,255,208)")
  screen.drawMap(mapsList[n], 0, 0, 384, 256)
end

Is there any way to not randomize the map so I can set it manually?

map=maps["nameMap"]
screen.drawMap(map, 0, 0, 384, 256)

@Pallet, as for my example above, you can simply assign to the variable "n" any number from the range from 0 to mapList.length - 1. Just n = 2 for example.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community