Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- How to set up world map camera zones
- -- This goes into your map.lua file, in the same folder as your .wld file.
- -- First, load camlock
- local camlock = require("camlock")
- -- The function camlock.addZone creates a camera zone at the given x and y coordinate, with a given width and height.
- -- The vanilla map boundary is 68 pixels left, right and down, and 130 pixels up. If you know the top left corner of your visible space, you will have to subtract 68 pixels on the x-axis and 130 pixels on the y-axis to find the true camera position.
- camlock.addZone(0, 0, 800, 600) -- This creates a single-screen camera zone with the camera in the top left corner at 0,0. If the world map border is active, this means the top left visible tile is at coordinate 68, 130. If the world map border is active, the visible area of one screen is 670x402 pixels.
- -- Copy the addZoneHelper function into your map.lua to make it easier to create camera zones with the world map border active. You give it the coordinate of the top left visible pixel, and the number of screens you want in terms of width and height.
- local function addZoneHelper(x, y, screensX, screensY)
- camlock.addZone(x - 68, y - 130, 130 + screensX * 670, 198 + screensY * 402)
- end
- -- Creates a 2-screen-wide camera zone with the top left corner being at coordinate x=64, y=128.
- addZoneHelper(64, 128, 2, 1)
- -- Creates a 3-screen-wide and 4.5 screen tall camera zone with the top left corner being at coordinate x=1120, y=-60.
- addZoneHelper(1120, -60, 3, 4.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement