Forum

> > CS2D > Scripts > Mathematic
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Mathematic

25 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Mathematic

xSkyLordx
User Off Offline

Zitieren
Hi Guys,

2 Days ago i detected, i cant use math.**
I need some math examples and i dont want LUA.ORG Exam because Lua.org examples not understandable for me

just some examp


THX,
1× editiert, zuletzt 07.11.11 17:31:58

alt Re: Mathematic

Bowlinghead
User Off Offline

Zitieren
Easiest sample I think:

1
print(math.random(1,3)) -- randomly selected number between 1 and 3!


But remember:
Every math.* function is different.
So you can't ask for 1 example and you know every math.* function!
1× editiert, zuletzt 07.11.11 17:37:14

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
THX BownlingHead,

but i cant RANDOM , COS , SIN , SQRT

i working hard but i cant understand :(((

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
i dont have any CODE because

Exam
addhook("say","randome")
if t=="randome"
NOTHING *-*
end
end

i need EXAM of All math

alt Re: Mathematic

TimeQuesT
User Off Offline

Zitieren
Actually you first have to know how to use lua.

edit:

1
2
3
4
5
6
7
8
addhook ("say","loldatthread"); --hooking the say event to a function
function loldatthread(id,txt) --declairing a function + (parameters) btw. starting a function

if (txt=="lol") then -- checks if the given text ist equal to "lol".
print(math.random(1,5)) --generates a random number between 1 to 5 and shows it in the console
end --end of the if block

end --end of function
2× editiert, zuletzt 07.11.11 17:47:18

alt Re: Mathematic

Bowlinghead
User Off Offline

Zitieren
Then you need something like this:
http://lua-users.org/wiki/MathLibraryTutorial

Because there are much math. functions.
Mehr >

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
Thx BownlingHead for Your help again but i know that but i cant use with Lua


Time Quest i can use end
i can

Adhook
Parse
Func (Wrapper)
END
TABLE ( table insert bla bla bla)
--

MATH NOO
1× editiert, zuletzt 07.11.11 17:53:35

alt Re: Mathematic

TimeQuesT
User Off Offline

Zitieren
Before you are able to use them you have to know the basics of lua...

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
i can use BASIC MAAAN i can lua just Math understand haa. I making Lua for 2 year. *-*

alt Re: Mathematic

TimeQuesT
User Off Offline

Zitieren
you have to handle math.xyz as function.

math.sqrt(value) --> will return the squareroot of 'value'<<

alt Re: Mathematic

DannyDeth
User Off Offline

Zitieren
So... basically, you have no knowledge of math? Like you don't know what 'atan' and 'acos' are?

alt Re: Mathematic

Bowlinghead
User Off Offline

Zitieren
And why you don't look at the lua.org page?

And btw just check out the page!
It is giving examples and describtion!
What do you want more?

alt Re: Mathematic

EngiN33R
Moderator Off Offline

Zitieren
user xSkyLordx hat geschrieben
i dont have any CODE because

Exam
addhook("say","randome")
if t=="randome"
NOTHING *-*
end
end

i need EXAM of All math


You need to learn the bloody basics of Lua itself first, for God's sake. Oh, and by the way, you do need a math exam. As well as an English exam for that, to be perfectly honest.

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
Okay

How can i find math exam. ??

i do not want Lua.org exam because

1
2
math.cos(0,5)
> 1

WHAT a HELL

alt Re: Mathematic

SQ
Moderator Off Offline

Zitieren
Dude,
Parameters are seperated with ","
You have to use a dot for float points ".5"

Um, not that I haven't scripted in lua for ages.

I think radian constant is something like
DEG_TO_RAD = 0.0174532925199432957692369076848861

1
math.cos(ANGLE*DEG_TO_RAD)
1× editiert, zuletzt 07.11.11 23:35:47

alt Re: Mathematic

xSkyLordx
User Off Offline

Zitieren
guys,

yess i know its a resul but

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
function drawLaserPointer(p)
	--if ( last_rot[p-1] ~= player(p,"rot") ) then
		local rot,x,y = (player(p,"rot")-90)*math.pi/180,player(p,"x"),player(p,"y");
		last_rot[p-1] = player(p, "rot");
		x = x + 16*math.cos(rot);
		y = y + 16*math.sin(rot);

		local scale = 32;

		if ( img_data[p-1] == -1 ) then
			img_data[p-1] = image("gfx/plot_.bmp",x,y,1,0);
		end

		while ( (not tile(ConvertCoord(x),ConvertCoord(y),"wall")) and (not tile(x, y, "playeron", p)) ) do
			x = x+math.cos(rot);
			y = y+math.sin(rot);
			scale = scale + 1;
			--imagepos(img_data[p-1], player(p,"x"), player(p,"y"), rot*180/math.pi);
		end
		if ( end_pnt[p-1] == -1 ) then
			end_pnt[p-1] = image("gfx/flare_fb.bmp", x, y, 1, 0)
		end
		imagepos(end_pnt[p-1], x, y, math.random(0, 360))
		imagescale(end_pnt[p-1], 0.1, 0.1)
		imagecolor(end_pnt[p-1], COLOR__[0], COLOR__[1], COLOR__[2])

		imagescale(img_data[p-1], findchange(32, scale),1);
		imagepos(img_data[p-1], player(p,"x")+(scale/2)*math.cos(rot), player(p,"y")+(scale/2)*math.sin(rot), rot*180/math.pi);
		imagecolor(img_data[p-1], COLOR__[0], COLOR__[1], COLOR__[2]);
		imagealpha(img_data[p-1], 0.65);
	--end
end


yess, after learning LUA.ORG Exam i can do that

i know what a Cos or what is a Random just cant use with CS2D Lua okay ??
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht