-
Notifications
You must be signed in to change notification settings - Fork 1
Core
Jump To | back |
Overview | Contents | Macros | Index |
---|
The Core module of FAST is what all other modules build on top of. It contains a series of low-level foundations and common functions such as data structures, a common event system, and a string parser. The Core module contains the only object used by FAST, __FASTtool
. This object is not required for most features to work, and can be removed/disabled by setting FAST_DISABLE_EVENTS
to true
, however doing so may require managing event features yourself, such as manually calling for Loggers to close on exit.
The first primary data structure in Core are the IterableListss. These are garbage-collected, pythonic structures built for data manipulation. FAST includes a large number of array-based functions that do many of the same tasks if you need to operate on arrays. The properties of these lists are they are traversable, meaning they can be walked without knowledge of their size or contents, and can be ordered or unordered. Ordered lists will use a binary search for find and insertion operations, but both the search and ordering logic can be overwritten should you have a certain requirement.
There are two types of map structures. The HashMap is a direct replacement for ds_map. The Dictionary on the other hand is an ordered HashMap which can be searched and traversed. That is to say it is possible to search for an element, and then retrieve the next element or the previous one. Be aware the dictionary is ordered, but not necessarily by order elements are added. In that case you should use a list. Instead the keys are ordered alphabetically by default.
Creating Events
Events are essentially methods that are bound to a specific timing. You can create events that will happen once after a number of frames, repeat after so many frames, or even ones that should happen 10 seconds from now. There are two event types FrameEvent and DeltaEvent. The two are identical except for how they measure when they should activate. Unsurprisingly, FrameEvents are based on frame-timing, and DeltaEvents are delta-timing. You can create an event by calling new
on one of these constructors:
event = new FrameEvent( FAST.STEP, 1, undefined, function() {
show_debug_message( "Hello World!" );
}
This would create an event that will print, "Hello World!" to the console every frame. If you'd like an event to only happen once, you can call once()
on the event, event when it's created:
event = new DeltaEvent( FAST.STEP_BEGIN, 10, undefined, function() {
show_debug_message( "Hello Once!" ):
}).once();
Additionally, you can use now()
if you would like the event to fire as soon as it is created. Since events are called via the FAST system, it isn't possible to know when during a step the event will be called. Thus this should generally only be used when you are sure that the event will not run during this frame.
Lastly, it's important to understand that the method that is passed to the event will be run at the scope it was bound to. This is highly convenient because it means you can write your Events as if they were running at the scope they were defined, but this means you should remember to clean up any events an instance or structure created when they are destroyed. You can use method()
to bind a function to a different scope when a Event is created as well.
name = "FAST";
event = new FrameEvent( FAST.STEP, 1, undefined, function() {
// this method will run as if it were part of the previous scope
show_debug_message( name );
}
Files are a part of GMS that can be unexpectedly annoying to deal with. FAST makes it easy to write your own file types while providing convenience features when dealing with them, for example:
var _text = new FileText( "log/debug.txt", true, false );
name = _text.read();
Here we open log/debug.txt
if it exists and read it into FileText. You can then read from and write to the file the same as you would anything else, and you can even insert lines or return to the beginning if needed. When you are done, simply call close()
and your changes will be saved to disk, or discard()
and they'll be ignored. You can also set the file to be read only which will protect against writing to or saving the file. FAST contains a few basic file types and more are added periodically. If there's a file type you'd like to see added, open an Issue and let me know!
Name | Type | Value | Description |
---|---|---|---|
FAST | func | ( FASTManager() ) | Wrapper |
__FAST_version | string | "3.5" | The current FAST revision |
__FAST_date | string | "06/12/2021" | The last revision date |
syslog | func | ( SystemOutput() ).write | Virtual function |
System | func | ( SystemOutput() ) | Wrapper |
FAST_DISABLE_EVENTS | bool | false | If set to true __FASTtool will not be instantiated |
Devon Mullane 2020