1{
2id: "buyable_item",
3zorder: -5,
4properties: {
5	number_owned: "level.player.number_of_item(real_item_name)",
6	final_price: "consts.price * (1 + number_owned)",
7	real_item_name: "regex_replace(type,'buyable_','')",
8},
9consts: {
10	max_owned: 1,
11	quantity: 1,
12},
13on_create: "[if(number_owned >= consts.max_owned, remove_object(me))]",
14on_interact: "[fire_event(level.player, 'start_interact')]",
15on_bought: "level.player.get_item(real_item_name,consts.quantity)",
16on_talk: "[set(level.player.time_in_animation_delta, 0),
17	         if(level.player.vars.coins < final_price,
18	            [
19	             paused_speech_dialog(self, consts.description + [~The price is ${final_price} coins.~, ~You don't have enough money.~]),
20				],
21				[
22				 paused_speech_dialog(self, consts.description + [~The price is ${final_price} coins.~]),
23				 paused_speech_dialog(self, [~Do you want to buy the ${consts.name}?~,
24				  ~Yes~, 	[
25				  		fire_event('bought'),
26				  		die(),
27				  		sound('coins-buy.wav'),
28				  		set(level.player.vars.coins, level.player.vars.coins - final_price),
29				  		spawn('text_flash_negative',midpoint_x,midpoint_y-20,1,[set_var('txt','-'+me.final_price)])
30				  		],
31				  'default_skip', ~No~, []])
32				]),
33			    set(level.player.time_in_animation_delta, 1)]",
34on_end_normal_anim: "animation('normal')",
35animation: {
36	id: "normal",
37	interact_area: "all",
38},
39}
40