Forum

> > CS2D > Scripts > Text coordinates not working in Visual Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Text coordinates not working in Visual Lua

3 replies
To the start Previous 1 Next To the start

old Text coordinates not working in Visual Lua

Denisgrad
User Off Offline

Quote
I am trying to rewrite the whole UI in my script with Visual Lua instead of just using f2 and f3 menus and text. But I encountered a problem right from the start. I am trying to change the welcome message and for some reason the button and the window pop up correctly but the text is all in the left top corner. Even though I set the x and y correctly.

Here is the code.
1
2
3
4
5
function cod_helpcline()
vl.createWindow(1,id,320,240,9,7,1,true,'Welcome')
local txt5=vl.createText(id,'000045000','Welcome to Call of Duty server!',150,150)
local txt6=vl.createText(id,"000450000",'Server Actions:!',150,350)
vl.createButton(1,1,384,310,1,"",function() vl.closeWindow(1) vl.removeButton(1) vl.removeText(txt5) vl.removeText(txt6) end)

Here is the image
http://oi68.tinypic.com/2nsw7.jpg

old Re: Text coordinates not working in Visual Lua

Gaios
Reviewer Off Offline

Quote
That's really outdated framework for Visual Lua.
Maybe you could try file File does not exist (17532) by user Masea which is modeled on my framework logic. This one is very easy but not really advanced.

You can also try my old framework, but I wrote its in bad syntax. I mean you need to add namespaces and instances everywhere. Also my framework adapt to every screen resolution, instead of rescaling GUI.
So you don't need to use cs2d cmd mp_hudscale 1.
> https://youtu.be/BAX3g7e9ODk

The choice is yours. I will say that Visual Lua doesn't work well for lagged players.

old Re: Text coordinates not working in Visual Lua

Denisgrad
User Off Offline

Quote
Thanks for your post. So I ended up using the GUI Framework by Masea and everything seemed to be working perfectly until I used "id" instead of 1 for player id.

1
2
3
4
5
6
7
8
9
10
button1 = gui.imageButton.create("gfx/cod-mod/gun_icon.png", 50, 265, 64, 64,id)
button1.onHover = function(img)
     imagecolor(img, 155, 155, 155)
end
button1.onClick = function()
     menu(button1.id,'Set up your Slot:,Primary weapon,Secondary weapon,Extra Grenade,Primary Perk,Secondary Perk,Killstreaks')
end
button1.onUnhover = function(img)
     imagecolor(img, 255, 255, 255)
end

The button1.onClick function does not work when I set the id from 1 to "id". The onHover and unHover functions work, the image is shown but the menu does not show up when I click the button. When I change the playerid to 1 everything works. I have no idea why it doesnt work since there are no errors in the server log.

EDIT: NVM, I feel really stupid I forgot to add local to button1. Now it works.

EDIT: Is there any way to disable primary and secondary attack using button1.onHover function ?
edited 2×, last 25.11.17 03:16:05 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview