Maplock Images - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Archives (https://www.save-point.org/forum-105.html) +--- Forum: Creation Asylum Archives (https://www.save-point.org/forum-90.html) +---- Forum: Scripts & Code Snippets (https://www.save-point.org/forum-92.html) +----- Forum: RPG Maker XP Code (https://www.save-point.org/forum-93.html) +------ Forum: Code Snippets & Others/Misc (https://www.save-point.org/forum-100.html) +------ Thread: Maplock Images (/thread-6627.html) |
Maplock Images - Khatharr - 06-08-2005 Maplock Images by Khatharr version 2 Jun 8 2005 This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss. No support is given. If you are the owner of the thread, please contact administration. Okay! The old maplock script was messy and buggy. I think it was one of the earlier scripts I did. This new one works great and is easy to install. There are two parts to this: one part allows you to 'spawn' a picture, the exact same way the 'show picture' does, so that you can 'spoof' this command from inside a script. The second part allows you to lock a picture to the map, so it will not follow the screen, but will stay put relative to the map. To install this script create a new section in the script editor just above "Main". Do this by scrolling the menu on the left-hand side all the way to the bottom, then right-clicking on "Main" and selecting "Insert". Name the section and then select it. Paste the following code into the right-hand pane. Code: #============================================================================== And that's it. Now, the 'picture spoofer' makes the game think that you used the 'Show Picture' command in an event. It actually sets up a picture the same way, so if you use it to make a picture, you could then remove that picture using the 'Erase Picture' event command, or you could use the move, rotate, and tint commands. The syntax to use it is as follows: Code: $game_screen.spoof_pic(number, filename, origin, x, y, zoom_x, zoom_y, opacity, blend_type) number - The number of the picture, 1 to 50. This is used by events to reference the picture. It is required to assign a number, even if you don't need it. filename - The name of the image. (Duhr...) The file must be in your pictures directory. Do not add the file extension. Before you complain about this, did you know that you can import more than one picture at a time? Just select the whole bunch of 'em on the 'open' dialog while importing. They will batch-import. It even remembers your color settings between images. Very convenient. No, I will not change this. Import your pics. If you want to show monster pics, import them. origin - 0 or 1. An origin of 0 means the x,y refers to the upper-left corner of the image. An origin of 1 means the x,y refers to the center of the image. x, y - This refers to the x, y on the screen (not the map!). To calculate a pixel location with reference to the map instead of the screen, you can use this formula: (Screen-relative X) - ($game_map.display_x / 4) = Map-relative X In other words, if you want to start your picture offscreen at a specific x,y on the map, such as 45,90, you would calculate as follows: scrolled_x = $game_map.display_x / 4 scrolled_y = $game_map.display_y / 4 target_x = 45 - scrolled_x target_y = 90 - scrolled_y and then feed the target_x and target_y values into the method. The screen is 640x480 logical pixels. zoom_x, zoom_y - Percentage of zoom. Set to 100 for normal size. opacity - The opposite of transparency. Set to 255 to make your picture normal. blend_type - Normal = 0; Add = 1; Subtract = 2 (Just like in 'Show Picture') And that's how the spoofer works. If you want to remove a picture from within script, use: Code: $game_screen.pictures[number].erase Fortunately the lock command is a lot simpler. Once you have created your picture, use Code: $game_screen.pictures[number].lock(x, y) And pass it a MAP x, y value. Use the method give above to convert to map x,y. You must pass an x, y location to the lock command. The old method of locking a picture wherever it lay is no longer present. There's also no longer an "unlock" command, as it was somewhat silly. To unlock a picture simply erase it and re-create it. The "Move Picture" event command can no longer be used on locked pictures. To move a picture that is locked just lock it to a new x,y location. You don't have to erase it first. A final note, tiles are 32x32, so if you want your x,y to be on the upper-left corner of map tile 8,6 then your x,y is: x = 8 * 32 = 288 y = 6 * 32 = 224 If you want your x,y in the center of the tile, just add 16 to both x and y. But you probably knew that. Thanks again for all the comments on the script and for your patience while waiting for version 2. Sorry it took so long. |