Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2107 108 109338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
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
1× editiert, zuletzt 29.11.09 14:40:35

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Zitieren
-WiLSoN- hat geschrieben
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!

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

StirlizZ-Fapicon
Super User Off Offline

Zitieren
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%"

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
Fapicon hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
@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
--]]--

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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...

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
@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

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
go to amx2d/core/mods.lua

Make the following revision

Line 72, change to

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

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Vibhor hat geschrieben
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.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Vectar666 hat geschrieben
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.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Like script with 2 languages?

Make a tables of language texts...
1
script_texts = {{1,"txt"}}..........
Zum Anfang Vorherige 1 2107 108 109338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht