Forum

> > CS2D > Scripts > [REQ]hudtxt2 positioning[TIBIA]
Forums overviewCS2D overview Scripts overviewLog in to reply

English [REQ]hudtxt2 positioning[TIBIA]

7 replies
To the start Previous 1 Next To the start

old [REQ]hudtxt2 positioning[TIBIA]

Runnin
User Off Offline

Quote
Hey members,

When i was working yesterday with the hudtx2 command,
I wanted to position some text on the screen but everytime i didn't know the exact postition on the screen.
So when i had it positioned it almost correctly i had to keep add one pixel and restart the server, saw that it was not perfecly at the right spot, change cordinates > restart the server and so on.

So my question is: Is there a tool or just a handy trick to know the exact cordinates where you want to put some text on the screen or a trick so i dont have to open and close the server every time to reload the LUA scripts.

Thanks in advance!

old Re: [REQ]hudtxt2 positioning[TIBIA]

DC
Admin Off Offline

Quote
screen coordinates in CS2D (x,y):
top left corner: (0,0)
bottom right corner: (640,480)

x = width (horizontal position)
y = height (vertical position)


You can execute the stuff right via the console (or even chat by adding an / at the beginning)

1
hudtxt2 1 0 "test text" x y 0

just copy&paste this line and change the x y values and enter it in the console/chat (don't forget to add the / in the beginning when using the chat)

Another solution would be to take a screenshot and to open it in Paint. Then simply point at the position where the text is supposed to be and read the coordinates at the bottom of the Paint window.

Also why the [TIBIA] in the title? cs2d cmd hudtxt2 is a regular CS2D command and not related to Tibia in any way. Even if you are using it for Tibia. It doesn't matter for this thread. The [REQ] is quite pointless as well. A better title would be "hudtxt2: finding right position" for example.

old Re: [REQ]hudtxt2 positioning[TIBIA]

Jynxxx
User Off Offline

Quote
@user DC: Tibia has it's function to use hudtxt2 like so...
1
2
3
function hudtxt2(id, txtid, text, colour, x, y, align)
	parse("hudtxt2 " .. id .. " " .. txtid .. " \"©" .. tostring(colour) .. text .. "\" " .. x .. " " .. y .. " " .. align)
end

So you will use...
1
hudtxt2(id,40, 'Testing', '255255255', 250,250,0)

@user Runnin: What I like to do to position a hudtext is just mess around with the numbers until I find the right location.

old help

mattasha
User Off Offline

Quote
@user Jynxxx: I used your code but not work

Look at this:

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
end
end

function remtimer(id)
	_TIMER[id] = nil
end

_print = print
function print(...)
	local txt = table.concat({...}, '\t')
	return _print(type(txt) == "table" and table.tostring(txt) or tostring(txt)) 
end

function drawLine(x1, y1, x2, y2, tbl)
	if not (x1 and y1 and x2 and y2) then
		return false
	end
	tbl = tbl or {}
	local line = image('gfx/weiwen/1x1.png', 0, 0, tbl.mode or 1)
	local x3, y3, rot = (x1+x2)/2, (y1+y2)/2, math.deg(math.atan2(y1-y2, x1-x2))+90
	imagepos(line, x3, y3, rot)
	imagescale(line, tbl.width or 1, math.sqrt((x1-x2)^2+(y1-y2)^2))
	if tbl.color then
		imagecolor(line, tbl.color[1] or 0, tbl.color[2] or 0, tbl.color[3] or 0)
	end
	if tbl.alpha then
		imagealpha(line, tbl.alpha)
	end
	if tbl.blend then
		imageblend(line, tbl.blend)
	end
	return line
end

function laser(id)
	local x, y, rot = player(id, 'x'), player(id, 'y'), math.rad(player(id, 'rot'))
	addtimer(1000, freeimage, drawLine(x, y, x+math.sin(rot)*300, y-math.cos(rot)*300, {width = 10, color = {math.random(0, 255), math.random(0, 255), math.random(0, 255)}, alpha = 0.5}))
	radiussound('weapons/laser.ogg', x, y)
end
function hudtxt2(id,40, 'Testing', '255255255', 250,250,0)
     parse("hudtxt2 " .. id .. " " .. txtid .. " \"©" .. tostring(colour) .. text .. "\" " .. x .. " " .. y .. " " .. align)
end

Look the Last sentens That's the code you said for @user Runnin:

@user Jynxxx: Please tell me if i get a Problem or i don't placed it in the correct place
Thanks

old Re: [REQ]hudtxt2 positioning[TIBIA]

Cure Pikachu
User Off Offline

Quote
1
2
3
function hudtxt2(id,40, 'Testing', '255255255', 250,250,0)
	parse("hudtxt2 " .. id .. " " .. txtid .. " \"©" .. tostring(colour) .. text .. "\" " .. x .. " " .. y .. " " .. align)
end
You are doing it wrong. *facepalm*
Fix (Lines 40-42):
1
2
3
4
5
function hudtxt2(id, txtid, text, colour, x, y, align)
	parse("hudtxt2 " .. id .. " " .. txtid .. " \"©" .. tostring(colour) .. text .. "\" " .. x .. " " .. y .. " " .. align)
end

hudtxt2(id,40, 'Testing', '255255255', 250,250,0)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview