Forum

> > CS2D > Scripts > LUA Question - Level system
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA Question - Level system

3 replies
To the start Previous 1 Next To the start

old LUA Question - Level system

Deleted User

Quote
Okay guys I got problem with my level system

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function objectdamage_hook(id, damage, player)
	if ob(id, 'type') == 8 then
		local dmg
		if damage > ob(id, 'health') then
			dmg = ob(id, 'health')
		else
			dmg = damage
		end
		money[player] = money[player] + (math.ceil(dmg / 2))
		xp[player] = xp[player] + dmg
		if xp[player] > xp_target[player] then
			xp_target[player] = xp_target[player] * 2
			level[player] = level[player] + 1
			pr('sv_sound2 '.. player ..' "pl_vs_turrets/levelup.ogg"')	
		end
	end
end

1st problem: after level 6 its hard train level like hell
2nd problem: admin commands if you set level, then
xp_targetmust incrase too
I cant really do that, can someone help me?

old Re: LUA Question - Level system

Ultimate programmer
BANNED Off Offline

Quote
1) what does mean " ob(id, 'type') "?
2) "money[player]" is array? Or you used it for unlimit money(>16000)? You wrote money{} or
money=initArray(32) for example? So use better " player(pl,"money") "

3)Do not use a lot of functions:
I have programmed for Microcontrollers and I have known that function take 4 commands so is large part of 100 command per second.Yes,computer have 100000000 commands per second,but where are more functions!

I have seen some stupid errors in my scripts-i have checked them-it is right,but lua show me errors

And use special programs for scripting:
If you are Windows user,use Programmers's notepad-it will show you commands of lua other color then others words. it mean word "arrow" is white,command "end" is blue, simbal + is red,comment is green. Download it at: http://www.megaupload.com/?d=1NKX2DQE

Give me full script

old Re: LUA Question - Level system

Lee
Moderator Off Offline

Quote
Quote
3)Do not use a lot of functions:
I have programmed for Microcontrollers and I have known that function take 4 commands so is large part of 100 command per second.Yes,computer have 100000000 commands per second,but where are more functions!


Personally, I disagree with this. Functions are the basis of modularity, which improves the clarity of the underlying code that you're writing. As such, having already chosen a language that introduces a lot of overhead in abstraction, the ultimate goal of the code is no longer about squeezing out every last drop of performance, but to balance your code between readability and performance.

old Re: LUA Question - Level system

Deleted User

Quote
I tought you are good prgrammer
(ultimate programmer)
Functions its very useful
Better use this
And I alreardy use good program for scripting...
function pl
it same as player
function ob
it same as object
function pr
it same as parse

money[id] its custom money array -.-

BTW: OMG LEE I dont understand every 3th word O.o
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview