Forum

> > CS2D > Scripts > Spawn item in breakable
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Spawn item in breakable

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Spawn item in breakable

Kel9290
User Off Offline

Zitieren
Pls i need script, when breakable with XY tile (X=50, Y=40) breaks on XY tile spawns item
1× editiert, zuletzt 31.12.10 10:58:54

alt Re: Spawn item in breakable

J4x
User Off Offline

Zitieren
here we go!
1
2
3
4
5
addhook("triggerentity","wtfbreak")
function wtfbreak(x,y)
if entity(50,40,"name") == name then
parse("spawnitem 10 50 40")
end

PS: Replace the word name with the name that you put to your entity....
2× editiert, zuletzt 30.12.10 21:24:11

alt Re: Spawn item in breakable

Kel9290
User Off Offline

Zitieren
FN_Nemesis hat geschrieben
here we go!
1
2
3
4
5
addhook("triggerentity","wtfbreak")
function wtfbreak(x,y)
if entity(50,40,"name") == name then
parse("spawnitem 10 50 40")
end

PS: Replace the word name with the name that you put to your entity....

=( i need when breakable with XY tile breaks (62 25) in X 62 and Y 25 parse spawnitem 10 62 25
1× editiert, zuletzt 31.12.10 08:11:28

alt Re: Spawn item in breakable

NKN
User Off Offline

Zitieren
TimeQuesT hat geschrieben
no you can't

Yes you can do that with map triggers
just put a breakable entity with
trigger "asd"

and item entity
in spawn select on trigger only
and write on name "asd"

and when you destroy that breakable that item will appear

alt Re: Spawn item in breakable

DannyDeth
User Off Offline

Zitieren
Very easy way to do this:
Spoiler >


6 lines in total, only 4 of which do something. Not hrad to make. Try reading info.txt, it is definitely a very useful and complete source of information, that is what I do whenever I need to research/confirm something about CS2D's Lua scripting engine. It helps a lot.

alt Re: Spawn item in breakable

Kel9290
User Off Offline

Zitieren
DannyDeth hat geschrieben
1
2
3
4
5
6
addhook("triggerentity","wtfbreak")
function wtfbreak(x,y)
	if( entity(x,y,"name")=="INSERT_ENTITY_NAME_HERE") then
		parse('spawnitem ID_OF_ITEM '..x..' '..y)
	end
end

and this not work ×
Spoiler >

alt Re: Spawn item in breakable

DC
Admin Off Offline

Zitieren
people... there's a cs2d lua hook break hook!

the code is basically correct but you have to replace "triggerentity" with "break".

let me explain why it DOES NOT work with triggerentity: triggerentity is only called when an entity is triggered. breaking a breakable does NOT count as triggering. It can trigger entities (if you enter entity names in the trigger field of the breakable) but it normally doesn't.

so triggering only occurs when one or more entity names are in the trigger field of an entity (and if the trigger-action of this entity is performed). in this case the triggerentity event will be performed for all entities which have been triggered.

p.s.: entering the same value for name and trigger in your breakable in order to use triggerentity anyways does not work, because the breakable entity will be removed completely when it breaks. this means that it can not be triggered anymore.
1× editiert, zuletzt 31.12.10 11:11:20

alt Re: Spawn item in breakable

DannyDeth
User Off Offline

Zitieren
Ok, well according to DC then this should work:
1
2
3
4
5
6
addhook("break","wtfbreak")
function wtfbreak(x,y)
     if(entity(x,y,"name")=="break1") then
          parse('spawnitem 10 '..x..' '..y)
     end
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht