i have a problem with it, it sometimes disappear from itself for no reason how can i fix it? or if theres any better image hud... ty
Forum
Scripts
localhud
localhud
20 repliesi have a problem with it, it sometimes disappear from itself for no reason how can i fix it? or if theres any better image hud... ty
DC: Sometimes they disappear randomly too.
_Yank: haha no. If you forgot to clear memory of variable that store image id, another function of removing image, can simply disappear such other image.1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
var1 = image() -- var1=1001 var2 = image() -- var2=1002 freeimage(var1) -- no var1=nil and it still store 1001 var3 = image() -- var3=1001 because it's free -- and now at eg. if player leave (hook): if var1 then 	freeimage(var1) 	-- so, it removed image with id from var3 (1001) end
edited 1×, last 20.07.15 08:05:34 pm
The Gajos: what is it?
Mami Tomoe: it's code with example that your code can (or must) has this defect.
The Gajos: That was confusing '-'But thanks for the tip, will try it out
BTW, DC still should fix this. I'm (We're ?) tired of always having to find workarrounds to get things working properly.
1
2
3
4
5
2
3
4
5
_freeimage = freeimage function freeimage(imgeid) 	_freeimage(imageid) 	-- such code with _G table :) end
Mami Tomoe: and then if someone will do it for you, you have to run (dofile) the script before main script.EDIT:
You needn't to say that
. edited 1×, last 21.07.15 05:12:56 pm
The Gajos: Dude, what a useless post --'Anyways, here's my fix (haven't been deep tested yet)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ifix = {
	image = image,
	freeimage = freeimage,
	data = {}
}
function image(path, ...)
	ifix.data[path] = ifix.data[path] or {}
	table.insert(ifix.data[path], false)
	ifix.data[path][#ifix.data[path]] = ifix.image(path, ...)
	return ifix.data[path][#ifix.data[path]]
end
function freeimage(object, ...)
	for path, data in pairs(ifix.data) do
		for key, core in ipairs(data) do
			if core == object then
				ifix.freeimage(core)
				table.remove(ifix.data[path], key)
				return
			end
		end
	end
	print("\169255000000Image["..object.."] not found!")
end
EDIT: Fixed a bug
EDIT2: Easier error handling
edited 3×, last 24.07.15 09:52:26 am
_Yank: where do i put my image location?
Mami Tomoe: No meme pls. Just save this script to newImageSystem.lua in sys/lua location and in your main script on FIRST line type:dofile('sys/lua/newImageSystem.lua')
Mami Tomoe has writtenimage location
not lua
and what meme...
Mami Tomoe has writtenlocal hud_img = image("gfx/7hud/full.png", 554, 300, 2)
Like this! but you have to do the things that I said.
Could you guys test it please ?
i tried this code but i dont know where to add this: "gfx/7hud/full.png"
1
ifix.image("gfx/7hud/full.png", ...)
1 
localhud
Offline
