Skip to content

adamwestman/defkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DefKit

A Component based scripts library for Defold engine inspired by the Game Maker studio visual scripting.

Usage

  1. Add latest zip URL as a dependency in your Defold project: https://github.com/adamwestman/defkit/archive/master.zip

  2. Add the object.script to your Game Object

  3. Add an Event scripts to your Game Object

  4. Add an Action scripts to your Game Object

  5. Select the Action script and point its event url at the Event script

Docs

Here are some of the common Event (input) and Action (output) -scripts

Events are input from different sources to which you can react and connect one or many actions. These range from user-input such as keys being pressed, instance lifecycle such as create and destroy, or collision betwen different instances to name a few.

General

  • on_create : invoked directly on create of the object.
  • on_destroy : invoked when the object is told to be removed.

Input

These scripts allow users to connect logic to input, as long as the referenced action_id is defined in the input definition file.

  • on_button : repeated for as long as the button is held down.
  • on_button_pressed : invoked once as the button is pressed down.
  • on_button_released : invoked once as the button is released after being pressed.

Contact

These scripts allow users to connect logic to contact between objects, as long as the objects both have collision-objects and masks are correctly setup.

  • on_collision : repeated as long as the object matching the collision group is in contact.

Time

These script allow users to connect logic to events related to time, either user-defined alarms or the normal update-cycle.

  • on_alarm : invoked when the set amount of seconds have passed since the user-defined timer was started.
  • on_Step : invoked each cycle/frame.

Actions are small blocks of logic that allow interraction in a multitude of ways; movement, creation and destruction to name a few.

Shared Information

Event : All Actions come with an "event" url parameter, this is how you connect which Event is the cause of this Action.

Target : Many but not all Actions also come with a Self, Other or Object Type parameter

Relative: Let the set value be influenced by context based values, depending on Action this could be worl-position or existing velocity among other things.

Variables: Many of the input-values also come with a "Var" option which is short for Variable. These enable passing dynamic values, either predefined or controlled using set_variable.

Basic

  • create : tell a Factory to create one instance of it's targetted game-object, at the given location.
  • destroy : tell the targetted game-object to be destroyed instantly.

Move

The actions let the user change position over time for targetted object, if set to relative the existing movement-speed will be taken in-to account.

  • move_fixed : given one or more directions, North, West, South, East or diagonals inbetween. Randoms between the given directions and move at the assigned speed.
  • move_free : given an angle value, move in that direction at the given speed.

Basic2

  • set_alarm : tell the specified alarm event to fire after a set amount of seconds.
  • set_score : set the current score value to the defined amount, or influence the existing by relative.
  • set_variable : set the specified variable to the defined number value, or influence the existing by relative.
  • draw_score : render the current score at the specified coordinate on the screen.

Controll

  • test_chance : roll a dice with set amount of sides to see if it gives a 1, then invoke other actions.
  • test_instance_count : count the amount of objects to see if they are "equal (0)", "less than (-1)" or "more than(1)" the specified amount, then invoke other actions.

Examples

Properties

properties example

This example display a number of DefKit scripts along with Defold components Sprite and Collision Object, which together create an object that can move and on collision with "point" objects destroy them.