English localhud

20 replies
Goto Page
To the start Previous 1 2 Next To the start
19.07.15 08:20:40 pm
Up
Goo
User
Offline Off
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
19.07.15 11:11:36 pm
Up
lennon
User
Offline Off
Put all script than we can do something
The game of year - CS2D
19.07.15 11:46:53 pm
Up
_Yank
User
Offline Off
Its a CS2D bug, you can't do anything about it. You will need to "redraw" the image manually.
20.07.15 12:11:55 am
Up
DC
Admin
Offline Off
All images are removed on roundstart if that's what you're talking about (this is intended behavior).
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
20.07.15 09:43:40 pm
Up
The Gajos
BANNED
Offline Off
@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.

Code:
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
20.07.15 10:28:10 pm
Up
Goo
User
Offline Off
@user The Gajos: what is it?
20.07.15 10:31:35 pm
Up
The Gajos
BANNED
Offline Off
@user Goo: it's code with example that your code can (or must) has this defect.
21.07.15 12:50:44 am
Up
_Yank
User
Offline Off
@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.
21.07.15 11:39:23 am
Up
Yates
Reviewer
Offline Off
Agreed. Freeimage should always set the variable used for the image to nil after being removed.
21.07.15 05:27:15 pm
Up
Goo
User
Offline Off
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...?
21.07.15 06:13:02 pm
Up
The Gajos
BANNED
Offline Off
Guys, because I don't have time in this moment, you can do it using _G table and:
Code:
1
2
3
4
5
_freeimage = freeimage
function freeimage(imgeid)
     _freeimage(imageid)
     -- such code with _G table :)
end

@user Goo: 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
21.07.15 06:52:17 pm
Up
_Yank
User
Offline Off
@user The Gajos: Dude, what a useless post --'

Anyways, here's my fix (haven't been deep tested yet)
Code:
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
21.07.15 09:41:29 pm
Up
Goo
User
Offline Off
@user _Yank: where do i put my image location?
21.07.15 09:48:03 pm
Up
The Gajos
BANNED
Offline Off
@user Goo: No meme pls. Just save this script to newImageSystem.lua in sys/lua location and in your main script on FIRST line type:
Code:
dofile('sys/lua/newImageSystem.lua')
21.07.15 09:57:12 pm
Up
Goo
User
Offline Off
user Goo has written:
image location

not lua
and what meme...
21.07.15 10:00:43 pm
Up
The Gajos
BANNED
Offline Off
user Goo 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.
21.07.15 10:24:46 pm
Up
_Yank
User
Offline Off
I think that the script is not working pretty well
Could you guys test it please ?
23.07.15 03:56:34 pm
Up
Goo
User
Offline Off
More >

i tried this code but i dont know where to add this: "gfx/7hud/full.png"
23.07.15 04:42:40 pm
Up
Fraizeraust
Moderator
Offline Off
Just replace "path" at 10 line near "ifix.image(path, ...)" with "gfx/7hud/full.png", so it'll be like this.
Code:
1
ifix.image("gfx/7hud/full.png", ...)
To the start Previous 1 2 Next To the start