Forum

> > CS2D > Scripts > How to optimize hudtxt's usage?[Solved]
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to optimize hudtxt's usage?[Solved]

14 replies
To the start Previous 1 Next To the start

old How to optimize hudtxt's usage?[Solved]

Mora
User Off Offline

Quote
Hello dear uss community.
Well, the problem may not be solved through using images as a hudtxt, i dont like this idea.

The main thing is that i have Inventory with hudtxt2 feature, and the problem is that i have many slots but lack of hudtxt2 free ids. I know myself that using alot of them is bad and etc, but:
may be there an one hudtxt2 id for one line of items in horizontal?
IMG:https://i.imgur.com/wYLKeDf.png


May be these all hutdtxts be one just somehow with fixpos?
Otherwise one guy told that i can hide info in tooltip. Any ideas?
edited 1×, last 09.08.19 08:45:49 pm

old Re: How to optimize hudtxt's usage?[Solved]

Masea
Super User Off Offline

Quote
I actually told you what you could do. That's the only legit way around here. Show the item's quantity only when players hover on them. You would save lots of hudtxts as well.

old Re: How to optimize hudtxt's usage?[Solved]

Masea
Super User Off Offline

Quote
You didn't, though. I didn't tell you to show the quantity in the tooltip but in slots. In fact, perhaps the tooltip idea could be better. Since your tooltip is at the center and truly big, otherwise it would be less noticeable in slots.

old Re: How to optimize hudtxt's usage?[Solved]

Gaios
Reviewer Off Offline

Quote
How can you be out of 49 hudtxts at the screen... lol? Anyway I use automatic dynamic assignment of free IDs for hudtxts. Just grabs the one that isn't used currently.

EDIT:
Aha... nice big inventory.. lol. Anyway it's interesting why it's limited to 49 haha.. probably of bandwidth size per tick. That's the limit of server-sided mods. At least they can do hudtxt package function that will send many compressed hudtxts to the client in single packet.

user Mora has written
may be there an one hudtxt2 id for one line of items in horizontal?

√ You need special algorithm GL

old Re: How to optimize hudtxt's usage?[Solved]

DC
Admin Off Offline

Quote
I think the limit of 50 is arbitrary. At least I don't remember why I chose exactly that limit.

I guess I could try to increase it for the next update. Shouldn't cause direct issues but of course more texts mean more data. So updating many texts frequently is still a pretty bad idea.

No idea how you could display more text. You already mentioned using images instead. That's the only solution I can think of. But of course that's pretty annoying to implement. You also need additional files (images for the digits) and it's less efficient (causing more traffic).

Using one text for a whole line of items works in theory if you pad the spaces with a lot of space characters. Unfortunately the font isn't mono space (characters have different sizes). Therefore you would have to write quite some code to get the positions somewhat right. The positioning would never be perfect though because you can't do pixel perfect positioning that way. All numbers in a line would jump a bit when a number in front of them changes.

old Re: How to optimize hudtxt's usage?[Solved]

Mora
User Off Offline

Quote
Well, about hudtxt2 limit is interesting, like, samely: mora images - more data, i dont actually know if there's an image limit, but you can place 50 images whose sizes are like my HUD of inventory. Anyway you can use alot of images same as hudtxt2 like, items on floor, images as hud and imageframed image etc.

Nothing would cause more traffic as long as you use good(Ain't like me :D), so even if there's limit will be like 100, a coder, if he dont wanna lag and if he understand what he's doing then is okay.
Right now "more traffic" cause alot of images and bad coding without optimizations.(like all my scripts :C)

The problem is that if I hide items amount it wouldn't be so informative, and is not that easy to know how much you have, otherwise you need to aim each item to know how much you have. In plans to make possible to combine some items to get another one, so thats why i wanna use hudtxts.

Well i've got y'all. I will check my code and graphics, maybe i can find solution to keep items hudtxt-ed. Like decreasing slots amount and adding pages.

old Re: How to optimize hudtxt's usage?[Solved]

DC
Admin Off Offline

Quote
Yes, like I said, there was no real reason for that limit. I probably just didn't expect that anyone will ever need more texts
I agree that it doesn't make much sense to have that limit.

I implemented a new limit yesterday and can confirm that the new limit will be 200 (0-199) in CS2D 1.0.0.9.
Why a new limit instead of an "infinite" (~65k actually) amount like images? That's because of the way it is implemented internally. I don't want to change the underlying code. I think 200 is enough for most cases.

The update will probably be released within the next 1-2 months (fixes and minor improvements only).

old Re: How to optimize hudtxt's usage?[Solved]

Mora
User Off Offline

Quote
Well, actually bad using cause lag and traffic))
Huh, nice to see that something is making even after one post, lol. Thank you much!

By the way, data of hudtxt2 that sends (traffic) depending on how much symbols is used there? So if for example i have a single hudtext2:
'Health: "..player(id,"health").."/Armour: "..player(id,"armor").."/Money: "..player(id,"money")..".'

it will show me: Health: 100/Armour: 0/Money: 10000.
And if i use
1
2
3
4
5
local h=player(1,"health")
local a=player(1,"armour")
local m=player(1,"money")
local text="Health: "..h.."/Armour: "..a.."/Money: "..m
parse('hudtxt2 id 1 text 20 20 20 20 20')

is there any difference in data, that sending to client?Because output the same.

/offtop, and please, you did blocked using "key" of "addbind" while you type text, if you affected about updates, then this blocking should also work while you in any cs2d menu and in options and especially in console.

old Re: How to optimize hudtxt's usage?[Solved]

Gaios
Reviewer Off Offline

Quote
user Mora has written
is there any difference in data, that sending to client?Because output the same.

Man, Lua is just interpreting language. The output data is send.. doesn't matter how did you code it. If it's still the same data at the end, there's no difference.

Also to let you know.. it's faster and better to use cs2d lua cmd imagealpha at created images instead of: creating new images and removing them. Every cs2d lua cmd image command contains path, x, y and stuff; every cs2d lua cmd imagealpha contains only alpha value.

old Re: How to optimize hudtxt's usage?[Solved]

Mora
User Off Offline

Quote
So if i have on my screen mine inventory and before used PDA and all items that are there, wouldn't it lag ATM, while even their alpha is 0? since images are still there.

old Re: How to optimize hudtxt's usage?[Solved]

Gaios
Reviewer Off Offline

Quote
@user Mora: If there are created like ~50 images at the screen but hidden (alpha 0) for sure it doesn't affect at the connection between server-client. It will only affect at a client's GPU.. but in fact 50 images at the screen is nothing.. also user SQ optimized image memory usage.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview