Forum

> > CS2D > Scripts > localhud
Forums overviewCS2D overview Scripts overviewLog in to reply

English localhud

20 replies
Page
To the start Previous 1 2 Next To the start

moved localhud

Mami Tomoe
User Off Offline

Quote
local hud_img = image("gfx/7hud/full.png", 554, 300, 2)
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

Admin/mod comment

This seems to be about CS2D not Stranded II. Moved /DC

old Re: localhud

_Yank
User Off Offline

Quote
Its a CS2D bug, you can't do anything about it. You will need to "redraw" the image manually.

old Re: localhud

DC
Admin Off Offline

Quote
All images are removed on roundstart if that's what you're talking about (this is intended behavior).

old Re: localhud

The Gajos
BANNED Off Offline

Quote
@user _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
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 10:05:34 pm

old Re: localhud

_Yank
User Off Offline

Quote
@user 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.

old Re: localhud

Yates
Reviewer Off Offline

Quote
Agreed. Freeimage should always set the variable used for the image to nil after being removed.

old Re: localhud

Mami Tomoe
User Off Offline

Quote
I have no idea what you guys are talking about... can someone give me a working script that will last forever? for hud image? or freeimage...?

old Re: localhud

The Gajos
BANNED Off Offline

Quote
Guys, because I don't have time in this moment, you can do it using _G table and:
1
2
3
4
5
_freeimage = freeimage
function freeimage(imgeid)
	_freeimage(imageid)
	-- such code with _G table :)
end
@user Mami Tomoe: and then if someone will do it for you, you have to run (dofile) the script before main script.


EDIT:
user _Yank has written
user The Gajos: Dude, what a useless post --'

You needn't to say that .
edited 1×, last 21.07.15 07:12:56 pm

old Re: localhud

_Yank
User Off Offline

Quote
@user 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
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 11:52:26 am

old Re: localhud

The Gajos
BANNED Off Offline

Quote
@user 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')

old Re: localhud

The Gajos
BANNED Off Offline

Quote
user Mami Tomoe has written
local hud_img = image("gfx/7hud/full.png", 554, 300, 2)

Like this! but you have to do the things that I said.

old Re: localhud

_Yank
User Off Offline

Quote
I think that the script is not working pretty well
Could you guys test it please ?

old Re: localhud

Mami Tomoe
User Off Offline

Quote
More >

i tried this code but i dont know where to add this: "gfx/7hud/full.png"

old Re: localhud

GeoB99
Moderator Off Offline

Quote
Just replace "path" at 10 line near "ifix.image(path, ...)" with "gfx/7hud/full.png", so it'll be like this.
1
ifix.image("gfx/7hud/full.png", ...)
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview