Forum

> > CS2D > Scripts > Spawn item in breakable
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn item in breakable

14 replies
To the start Previous 1 Next To the start

old Spawn item in breakable

Kel9290
User Off Offline

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

old Re: Spawn item in breakable

J4x
User Off Offline

Quote
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....
edited 2×, last 30.12.10 09:24:11 pm

old Re: Spawn item in breakable

Kel9290
User Off Offline

Quote
FN_Nemesis has written
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
edited 1×, last 31.12.10 08:11:28 am

old Re: Spawn item in breakable

NKN
User Off Offline

Quote
TimeQuesT has written
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

old Re: Spawn item in breakable

DannyDeth
User Off Offline

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

old Re: Spawn item in breakable

Kel9290
User Off Offline

Quote
DannyDeth has written
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 >

old Re: Spawn item in breakable

DC
Admin Off Offline

Quote
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.
edited 1×, last 31.12.10 11:11:20 am

old Re: Spawn item in breakable

DannyDeth
User Off Offline

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