diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 67bcbeeec4..0c8070a2b1 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -514,6 +514,7 @@ {"id":{"name":"spr_weapon_chainfist_small","path":"sprites/spr_weapon_chainfist_small/spr_weapon_chainfist_small.yy",},}, {"id":{"name":"spr_popup_event_avatar","path":"sprites/spr_popup_event_avatar/spr_popup_event_avatar.yy",},}, {"id":{"name":"spr_scout_colors2","path":"sprites/spr_scout_colors2/spr_scout_colors2.yy",},}, + {"id":{"name":"obj_timer","path":"objects/obj_timer/obj_timer.yy",},}, {"id":{"name":"spr_popup_select","path":"sprites/spr_popup_select/spr_popup_select.yy",},}, {"id":{"name":"spr_ih_mk7_helm","path":"sprites/spr_ih_mk7_helm/spr_ih_mk7_helm.yy",},}, {"id":{"name":"spr_company_title","path":"sprites/spr_company_title/spr_company_title.yy",},}, @@ -633,6 +634,7 @@ {"id":{"name":"spr_manta","path":"sprites/spr_manta/spr_manta.yy",},}, {"id":{"name":"spr_ship_leviathan","path":"sprites/spr_ship_leviathan/spr_ship_leviathan.yy",},}, {"id":{"name":"spr_ship_razorfiend","path":"sprites/spr_ship_razorfiend/spr_ship_razorfiend.yy",},}, + {"id":{"name":"scr_wait_and_execute","path":"scripts/scr_wait_and_execute/scr_wait_and_execute.yy",},}, {"id":{"name":"spr_ship_stalker","path":"sprites/spr_ship_stalker/spr_ship_stalker.yy",},}, {"id":{"name":"spr_weapon_plasc","path":"sprites/spr_weapon_plasc/spr_weapon_plasc.yy",},}, {"id":{"name":"spr_ba_mk5_helm","path":"sprites/spr_ba_mk5_helm/spr_ba_mk5_helm.yy",},}, diff --git a/objects/obj_timer/Create_0.gml b/objects/obj_timer/Create_0.gml new file mode 100644 index 0000000000..c9483e3a31 --- /dev/null +++ b/objects/obj_timer/Create_0.gml @@ -0,0 +1,4 @@ +time_set = 0; +time_passed = 0; +end_function = undefined; +end_function_args = []; diff --git a/objects/obj_timer/Step_0.gml b/objects/obj_timer/Step_0.gml new file mode 100644 index 0000000000..451373f5da --- /dev/null +++ b/objects/obj_timer/Step_0.gml @@ -0,0 +1,15 @@ +if (time_set > 0) { + if (time_passed < time_set) { + time_passed++; + show_debug_message(time_passed); + } else { + if (is_method(end_function)) { + show_debug_message("Executing Method!"); + method_call(end_function, end_function_args); + } + show_debug_message("Killing Myself!"); + instance_destroy(self); + } +} else { + instance_destroy(self); +} diff --git a/objects/obj_timer/obj_timer.yy b/objects/obj_timer/obj_timer.yy new file mode 100644 index 0000000000..038cee7d7d --- /dev/null +++ b/objects/obj_timer/obj_timer.yy @@ -0,0 +1,34 @@ +{ + "resourceType": "GMObject", + "resourceVersion": "1.0", + "name": "obj_timer", + "eventList": [ + {"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,}, + {"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,}, + ], + "managed": true, + "overriddenProperties": [], + "parent": { + "name": "Objects", + "path": "folders/Objects.yy", + }, + "parentObjectId": null, + "persistent": true, + "physicsAngularDamping": 0.0, + "physicsDensity": 0.0, + "physicsFriction": 0.0, + "physicsGroup": 1, + "physicsKinematic": false, + "physicsLinearDamping": 0.0, + "physicsObject": false, + "physicsRestitution": 0.0, + "physicsSensor": false, + "physicsShape": 1, + "physicsShapePoints": [], + "physicsStartAwake": true, + "properties": [], + "solid": false, + "spriteId": null, + "spriteMaskId": null, + "visible": false, +} \ No newline at end of file diff --git a/scripts/scr_wait_and_execute/scr_wait_and_execute.gml b/scripts/scr_wait_and_execute/scr_wait_and_execute.gml new file mode 100644 index 0000000000..5711b8c3e7 --- /dev/null +++ b/scripts/scr_wait_and_execute/scr_wait_and_execute.gml @@ -0,0 +1,13 @@ +/// @mixin +/// @desc Waits for a set amount of steps and executes a function/codeblock. +/// @arg {real} timer In steps, will be multiplied by (room speed / 30). +/// @arg {function} func +/// @arg {array} func_args +function wait_and_execute(timer, func, func_args = []) { + var _timer_obj = instance_create(0, 0, obj_timer); + with(_timer_obj){ + time_set = timer * (room_speed / 30); + end_function = func; + end_function_args = func_args; + } +} diff --git a/scripts/scr_wait_and_execute/scr_wait_and_execute.yy b/scripts/scr_wait_and_execute/scr_wait_and_execute.yy new file mode 100644 index 0000000000..48282ee73c --- /dev/null +++ b/scripts/scr_wait_and_execute/scr_wait_and_execute.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "scr_wait_and_execute", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "Scripts", + "path": "folders/Scripts.yy", + }, +} \ No newline at end of file