Forum

> > CS2D > Scripts > Button Image?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Button Image?

9 replies
To the start Previous 1 Next To the start

old Button Image?

Rygna
User Off Offline

Quote
Hi!,
hey!, can you help me?
how to make Button Image?
i mean Make Button on screen with Image like custom GFX.

i try Visual Lua by user EngiN33R, that too hard for me.
if you can example how to make like that..
plase show me

thanks.

old Re: Button Image?

Gaios
Reviewer Off Offline

Quote
I lol'd. Visual Lua is for advanced scripters and you even don't know how to script very simple script.. as I said before, add me on skype and I will learn you.

It's not easy as well.. there so many things to care.

old Re: Button Image?

_Yank
User Off Offline

Quote
@user Gaios: Personally I think that that is incorrect. @user EngiN33R's VisualLua was made to help lazy (or not) scripters or scripters with less knowledge.

old Re: Button Image?

GeoB99
Moderator Off Offline

Quote
I guess that's too far to make a Visual Lua script. From my perspective you don't seem to get used to most of things in Lua like arrays, tables and much more which a Visual Lua uses it.

I'd suggest you to read Lua Pil 1 (you can also check for other tutorials in Google) tutorial which covers up all the parts of Lua programming language so you can cope with most of those such as a table, an array, the correct usage of statements and many things.

Once you've got the main principle basics of most of things, you can take a look at an example of a Visual Lua code (in this case check user EngiN33R's Visual Lua script) and (maybe?) you can make a Visual Lua script in your own.

old Re: Button Image?

Zeik
User Off Offline

Quote
You have to use the cs2d lua hook attack hook to call the cs2d lua cmd reqcld function (this way you can tell the player has clicked the screen), which runs the cs2d lua hook clientdata hook.
In the cs2d lua hook clientdata function you have to check where the player has actually clicked, to know wether he clicked the button or not. If he clicked the button, then you call the button's function to do whatever you want it to.

old Re: Button Image?

THEMUD
User Off Offline

Quote
@user Rygna: Here is an explanation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("attack", "_attack")
function _attack(id)
	reqcld(id, 2);
end

addhook("clientdata", "_cd")
function _cd(id, mode, data1, data2)
	if mode == 2 then
		if data1 == YOUR_DESIRED_X_POSITION then
			if data2 == YOUR_DESIRED_Y_POSITION then
				--Do your script here
			end
		end
	end
end

Or if you don't want to make the X and the Y really precised, you can let them between two values like this:
1
2
3
4
5
if data1 > YOUR_POSITION and data1 < YOUR_POSITION2 then
	if data2 > YOUR_POSITION and data2 < YOUR_POSITION2 then
		--Do your script here
	end
end
And I recommend this option. Because it gives the X and the Y the freespace they want and it will let you click on them efficiently.
edited 1×, last 26.01.16 01:50:30 pm

old Re: Button Image?

Rygna
User Off Offline

Quote
√ @user THEMUD, Hey!, thanks for explanation!.
that was great, i will test it.
√ @user Gaios, ok bro!, i will learn basic lua thanks.

Very thanks.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview