Forum

> > CS2D > Maps/Editor > [TUTORIAL]How to put images in map
Forums overviewCS2D overview Maps/Editor overviewLog in to reply

English [TUTORIAL]How to put images in map

3 replies
To the start Previous 1 Next To the start

old [TUTORIAL]How to put images in map

MikuAuahDark
User Off Offline

Quote
∗ Description ∗
This tutorial show you how to put a image file in a map with a Trigger_If
Please note that it would suddenly increase the map size

∗ Requirements ∗
Counter-Strike 2D 0.1.2.1 or above(earlier version does not have Trigger_If)
A Notepad++ or HexEdit

∗ How To
1. Create a new map/load an existing map
2. Add Trigger_If and Trigger_Start
3.
3.1: Trigger_If = Name: ImageInMap | Condition/Statement: Here
3.2: Trigger_Start = Trigger: ImageInMap
4. Save
5. Run this code to get a ascii code of a file that can used for lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
_pathtoimage="<path to image>"
_temp=assert(io.open(_pathtoimage,"rb"))
_txt=_temp:read("*a")
_temp:close()
_temp=io.open(_pathtoimage..".txt","w")
for w in _txt:gmatch(".") do
	local b=w:byte()
	if (b>=32 and b<=47) or (b>=58 and b<=126) then
		local t=w:gsub("\"","\\\"")
		_temp:write(t)
	else
		_temp:write("\\"..b)
	end
end
_temp:close()
Change a nessecary variable value
6. Go to folder where the image file are located and open <imagename>.<ext>.txt with text editor(filename can be different)
7. Copy all text inside that file
8. Go to maps folder and open your map with a Notepad++ or HexEdit(DON'T USE MICROSOFT NOTEPAD. IT WOULD JUST NOT WORK)
9. Find a text called "ImageInMap" in a map that you open
10. Replace "Here" text(should located near "ImageInMap" text) with this code:
1
(function() local temp=io.open("<pathtoimage>","r") if temp==nil then temp=io.open("<pathtoimage>","wb") temp:write("<Text that you copy from the text file>") temp:close() end return false)()
Change a nessecary value
11. Save and try to delete the image file(copy first in case of Errors)
12. Start a new game with the map that has that script(step 1)
13. If it works. it would throw some error on console(NOT LUA ERRORS)
NOTE: if you gonna render the image with cs2d lua cmd image then skip step 14
14. Just re-start your server(use cs2d cmd changemap) and the image will showed.

∗ Example Map ∗
• ImageInMap: It uses worklight.bmp at gfx/sprites and display it with cs2d lua cmd image | By user MikuAuahDark

To add the example map just give me the map link, map name, and some information(e.x.: what image is used) on comments
edited 2×, last 05.08.13 12:32:40 pm

old Greget

Alonz
User Off Offline

Quote
Greget Sekali [Mad Dog Greget]
To the start Previous 1 Next To the start
Log in to reply Maps/Editor overviewCS2D overviewForums overview