Forum

> > CS2D > Scripts > Mathematic
Forums overviewCS2D overview Scripts overviewLog in to reply

English Mathematic

25 replies
Page
To the start Previous 1 2 Next To the start

old Mathematic

xSkyLordx
User Off Offline

Quote
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,
edited 1×, last 07.11.11 05:31:58 pm

old Re: Mathematic

Bowlinghead
User Off Offline

Quote
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!
edited 1×, last 07.11.11 05:37:14 pm

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
THX BownlingHead,

but i cant RANDOM , COS , SIN , SQRT

i working hard but i cant understand :(((

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
i dont have any CODE because

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

i need EXAM of All math

old Re: Mathematic

TimeQuesT
User Off Offline

Quote
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
edited 2×, last 07.11.11 05:47:18 pm

old Re: Mathematic

Bowlinghead
User Off Offline

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

Because there are much math. functions.
More >

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
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
edited 1×, last 07.11.11 05:53:35 pm

old Re: Mathematic

TimeQuesT
User Off Offline

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

old Re: Mathematic

xSkyLordx
User Off Offline

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

old Re: Mathematic

TimeQuesT
User Off Offline

Quote
you have to handle math.xyz as function.

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

old Re: Mathematic

DannyDeth
User Off Offline

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

old Re: Mathematic

Bowlinghead
User Off Offline

Quote
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?

old Re: Mathematic

palomino
User Off Offline

Quote
Look up on lua.org
It's the only place for questions like this.

old Re: Mathematic

EngiN33R
Moderator Off Offline

Quote
user xSkyLordx has written
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.

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
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

old Re: Mathematic

SQ
Moderator Off Offline

Quote
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)
edited 1×, last 07.11.11 11:35:47 pm

old Re: Mathematic

xSkyLordx
User Off Offline

Quote
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 ??
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview