Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2107 108 109338 339 Next To the start

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
thanks
EDIT:
i've got a wrapper for healing:
1
2
3
function heal(id,hp)
	parse("sethealth "..id.." "..(player(id,"health") + hp)
end
but it doesn't work :S please correct it
edited 1×, last 29.11.09 02:40:35 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Where do you wanna put it?
There was "(" which closed parsing and coused bug.

1
2
3
function heal(id,hp)
	parse('sethealth '..id..' '..player(id,"health") + hp)
end

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
-WiLSoN- has written
thanks
EDIT:
i've got a wrapper for healing:
1
2
3
function heal(id,hp)
	parse("sethealth "..id.." "..(player(id,"health") + hp)
end
but it doesn't work :S please correct it
I think you gotta assign it a variable with value.

Somewhat like this but in another way...
Info about the script.
Spoiler >

Script below.
Spoiler >
Good luck!

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I just found out something very interesting
a few weeks ago

1
2
3
4
5
6
7
8
function spawnobject(type,tilex,tiley,rot,mode,team,pl)
	parse("spawnobject "..type.." "..tilex.." "..tiley.." "..rot.." "..mode.." "..team.." "..pl)
end

BUT if you put Team= 3 then it summons up
"SPECTATOR" type objects(do no harm to you)

Also They appear white.. So it's kinda awesome =D
ALSO with that
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("build","buildtest")
	function buildtest(i,t,x,y)
	   spawnobject(type,x,y,90,0,team,i)
	end
--[[--
Builds DOUBLE Layers of that same building
pretty awesome..
Basically If you build a wall 3
then another wall 3 is built in it also
so you would have to destroy the first wall 3 then the second =D
Oh and when you use dispenser with this it makes the light surrounding the dispenser giant
and TURRETS, the 1st turret(turret(norm)) covers the second turret(which you upgrade)))(norm turret can't be upgraded))
The first covers second so ppl only see a turret(norm) with the Second Turret's type over it like
example.
1st turret(norm)
2nd turret(Triple Turret)

the 1st covers second
but has second's name
--]]--

I found these things hella awesome =P

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Ok, I've just realized about a quite stupid error of my part
1
2
3
4
5
6
7
initArray(s,v)
	local table = {}
	for i=1,s do
		table[i] = v
	end
	return table
end

With that function you CAN'T make an array of tables.
1
table_of_tables = initArray(32,{health = 0, armor = 1})
That is WRONG because all the tables would point to the same table. This means that:
1
table_of_tables[2].health = 200
Will make that every index of table_of_tables will have their "health" to 200.

To avoid that we must edit the initArray function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function initArray(size,value)
	local tbl={}
	local istable = false
	if type(value)=="table" then istable = true end
	for i = 1, size do
		if istable then 
			tbl[i] = {}
			for d,v in pairs(value) do
				tbl[i][d]=v
			end
		else
			tbl[i] = value
		end
	end
	return tbl
end

That way we will create a new table for each index.

old Re: Lua Scripts/Questions/Help

StirlizZ-Fapicon
Super User Off Offline

Quote
Who have this script:
when your hp 100% - you can see green text in corner of screen: "Health - 100%"
If 75% - yellow text: "Health - 75%"
If 50% - orange text: "Health - 50%"
If 25-0% - yellow text: "Health - 25%"

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Fapicon has written
Who have this script:
when your hp 100% - you can see green text in corner of screen: "Health - 100%"
If 75% - yellow text: "Health - 75%"
If 50% - orange text: "Health - 50%"
If 25-0% - yellow text: "Health - 25%"


you can see that on samples/console.lua ,
just need some change only

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
@CMdark
I do not get this I got the first one but...
What to do?

addhook("build","buildtest")
function buildtest(i,t,x,y)
spawnobject(type,x,y,90,0,team,i)
end
--[[--
Builds DOUBLE Layers of that same building
pretty awesome..
Basically If you build a wall 3
then another wall 3 is built in it also
so you would have to destroy the first wall 3 then the second =D
Oh and when you use dispenser with this it makes the light surrounding the dispenser giant
and TURRETS, the 1st turret(turret(norm)) covers the second turret(which you upgrade)))(norm turret can't be upgraded))
The first covers second so ppl only see a turret(norm) with the Second Turret's type over it like
example.
1st turret(norm)
2nd turret(Triple Turret)

the 1st covers second
but has second's name
--]]--

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I just found out something very interesting
a few weeks ago

1
2
3
4
5
6
7
8
function spawnobject(type,tilex,tiley,rot,mode,team,pl)
	parse("spawnobject "..type.." "..tilex.." "..tiley.." "..rot.." "..mode.." "..team.." "..pl)
end

BUT if you put Team= 3 then it summons up
"SPECTATOR" type objects(do no harm to you)

Also They appear white.. So it's kinda awesome =D
ALSO with that
1
2
3
4
5
6
7
8
9
10
[b] Oops Fixed[/b]
addhook("build","buildtest")
	function buildtest(i,t,x,y)
	   spawnobject(t,x,y,90,0,player(i,"team"),i)
	end

Basically this uses the wrapper in first code
so that when you build something
it spawns that object in that spot already
and another of that object gets built there

So Basically so use this

just

1
2
3
4
5
6
7
8
function spawnobject(type,tilex,tiley,rot,mode,team,pl)
	parse("spawnobject "..type.." "..tilex.." "..tiley.." "..rot.." "..mode.." "..team.." "..pl)
end

addhook("build","buildtest")
	function buildtest(i,t,x,y)
	   spawnobject(t,x,y,90,0,player(i,"team"),i)
	end
i = playerid
t = objecttype
x = objectx
y = objecty
yeah...

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
whats the script where when you click on turrets, it opens up another menu with single, double, and triple turrets? and a free dispenser.

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@jackisokay2
thats pretty easy
1
2
3
4
5
6
7
8
9
10
addhook("build","sdtturret")
	function sdtturret(i,t,x,y)
		if (t==8) then
---Menu stuff---

menuselect
blah blah

yatayatayata do it yourself yata
-----------------

@LEEGAO
AMX2D ERROR
LUA ERROR: amx2d/core/menu.lua:50: table index is nil

menu.lua:93 attempt to index field '?' (a nil value)

help meh man

your help menu wont open correctly
T_T

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
go to amx2d/core/mods.lua

Make the following revision

Line 72, change to

local n = string.split(g, "_")

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Vibhor has written
how to make tiles for maps?
and how to decide whether it will be an obstacle,floor or a wall?

Is that about Lua or mapping? It's Lua tread, not maps...

DC haven't added tile(x,y) function so you should get script something on your own.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Vectar666 has written
You can use Image thing, read it in "info.txt" file in lua folder. It makes image in different conditions

Everyone knows that, no one asked it...
By the way function imagepos() have bug with explosions near.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Like script with 2 languages?

Make a tables of language texts...
1
script_texts = {{1,"txt"}}..........
To the start Previous 1 2107 108 109338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview