diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bdc01960..74904c219 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: shell: cmd working-directory: Manual - name: Upload robohelp zip file - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: YoYoStudioRoboHelp path: output\RoboHelp\*.zip diff --git a/Manual/contents/Additional_Information/Errors/Compiler_Errors.htm b/Manual/contents/Additional_Information/Errors/Compiler_Errors.htm index cfbfcbdf2..8e06ebde7 100644 --- a/Manual/contents/Additional_Information/Errors/Compiler_Errors.htm +++ b/Manual/contents/Additional_Information/Errors/Compiler_Errors.htm @@ -162,7 +162,7 @@

Compile Errors

Cannot use an argument outside a script  - The built in argument variables can only be used inside a script but you have tried to use them elsewhere + The built-in argument variables can only be used inside a script but you have tried to use them elsewhere No references to argument[num] but references argument[num] @@ -203,8 +203,8 @@

Compile Errors

You have tried to set a variable that is read only - Cannot re-declare a built in variable - You have tried to declare a local variable using the same name as one of the built in variables + Cannot re-declare a built-in variable + You have tried to declare a local variable using the same name as one of the built-in variables Cannot use resource name for a variable @@ -483,7 +483,7 @@

Compile Errors

Next: Runner Errors
-
© Copyright YoYo Games Ltd. 2024 All Rights Reserved
+
© Copyright YoYo Games Ltd. 2025 All Rights Reserved

Guide To Using Buffers

A buffer (in programming) is basically a space within the system memory that is used to store small packets of data for just about anything (for example: data transfer, collisions, colour data, etc.). Since it is held in system memory it is very fast to access, and a buffer would generally be used for very short-term storage, like receiving network information before processing it, or for storing a checkpoint in your game (this is explained in the example given further down the page).

-

Buffer MemoryBuffers are created by allocating a space in the system memory, calculated in byte s, which is then reserved for your game as long as your game is running or until you delete the buffer using the appropriate function (you can find all the GML buffer functions listed here). This means that even when your game is not in focus (for example, on a mobile device when you take a call the game will be put into the background) the buffer will still exist, however if the game is closed or re-started the buffer will be lost.

+

Buffer MemoryBuffers are created by allocating a space in the system memory, calculated in byte s, which is then reserved for your game as long as your game is running or until you delete the buffer using the appropriate function (you can find all the GML buffer functions listed here). This means that even when your game is not in focus (for example, on a mobile device when you take a call the game will be put into the background) the buffer will still exist, however if the game is closed or re-started the buffer will be lost.

 Restarting the game will not clear or delete the buffer! But it will prevent any further access to the previously created buffer as the ID handle will have been lost, causing a memory leak which will crash your game eventually. So, when re-starting a game, remember to delete any buffers first.

GameMaker permits the creation of four different buffer types. The reason for this is that buffers are designed to be a highly optimised temporary storage medium, and as such you should create a buffer that is appropriate to the type of data that you wish it to store, otherwise you could get errors or cause a bottleneck in your code. Before explaining this further, let's look at the four available buffer types (defined as constants in GML):

 

- - - - - - - - - - - - - - - - - - - - - - - -
ConstantDescription
buffer_fixed
- A buffer of a fixed size in bytes. The size is set when the buffer is created and cannot be changed again.
buffer_grow
- A buffer that will grow dynamically as data is added. You create it with an initial size (which should be an approximation of the size of the data expected to be stored), and then it will expand to accept further data that overflows this initial size.
buffer_wrap
- A buffer where the data will wrap. When the data being added reaches the limit of the buffer size, the overwrite will be placed back at the start of the buffer, and further writing will continue from that point.
buffer_fast
- This is a special "stripped down" buffer that is extremely fast to read/write to. However it can only be used with buffer_u8 data types, and must be 1 byte aligned. (Information on data types and byte alignment can be found further down this page).
+

 

Those are the buffer types available to you when using GameMaker, and which one you choose will greatly depend on the use you wish to put it to. For example, a grow buffer would be used for storing a "snapshot" of data to create a save game since you do not know the actual amount of data that is going to be placed in it, or a fast buffer would be used when you know that the values you are working with are all between 0 and 255 or -128 and 127, for example when processing ARGB data from an image.

Buffer TypesWhen creating a buffer, you should always try to create it to a size that is appropriate to the type, with the general rule being that it should be created to accommodate the maximum size of data that it is to store, and if in doubt, use a grow buffer to prevent overwrite errors.

@@ -55,7 +28,7 @@

Guide To Using Buffers

player_buffer = buffer_create(16384, buffer_fixed, 2);


That would create a fixed buffer of 16384 bytes and byte-aligned to 2, with the function returning a buffer handle that is stored in a variable for later referencing of this buffer.

-

When reading and writing data to a buffer, you do it in "chunks" of data defined by their "data type". The "data type" sets the number of bytes allocated within the buffer for the value being written, and it is essential that you get this correct otherwise you will get some very strange results (or even errors) for your code.

+

When reading and writing data to a buffer, you do it in "chunks" of data defined by their "data type". The "data type" sets the number of bytes allocated within the buffer for the value being written, and it is essential that you get this correct, otherwise you will get some very strange results (or even errors) for your code.

Buffers are written to (and read from) sequentially, in that one piece of data is written after another, with each piece of data being of a set type. This means that you should ideally be aware of what data you are writing to the buffer at all times. These data types are defined in GML by the following constants:

So, say you have created a buffer and you want to write information to it, then you would use something like the following code:

@@ -136,7 +109,7 @@

Guide To Using Buffers
Next: Bitwise Operators
-

© Copyright YoYo Games Ltd. 2024 All Rights Reserved
+
© Copyright YoYo Games Ltd. 2025 All Rights Reserved
-

Constructing Action Block Code

-

To add behaviours to objects you can construct your code using Actions from the different libraries available to you from the Action Toolbox. To start with you'll need to make a new GML Visual project and then make a new object (you can assign a sprite to the object too if required). In your new object you can start to add events, and in the events add your GML Visual code actions.

-

GML Visual Create EventNote that when you add a new event, a "code" window is opened with a tab for the given event (see the image above), and you can now drag any action you wish from the Toolbox on the right into the Action Block pane of the code window. Now, while it's true that you can add any action, that doesn't mean that they will all work or that the project will compile with them. Some actions require at least one variable to work, while others - like the Draw actions - will only work if used in a specific event. How do you know which ones to use? Well, generally, it's simply a question of using logic... if an action requires a variable and we haven't defined one yet, then we shouldn't be using it until we've added an action to create the variable.

-

When you drag an action from the Toolbox into the main Action Block workspace, it will expand to show you the available arguments (parameters) that you can fill in and change to set the behaviour. In the image below, we have dragged an Assign Variable action from the Toolbox Common library into the action block workspace:

-

GML Visual Assign VariableYou can see that the new action is also shown on the left of the code window in a shorthand form. This list of actions, called the action Overview, can be clicked on to quickly navigate to that action for editing. You can continue to add actions to the event should you need to, with each new action being "chained" to the previous one to show the flow of the GML Visual code you are constructing. Note that the area where you can drop further actions is highlighted for you underneath the initial action, and, depending on the action you are using, different areas will highlight to show where in the chain you can add it:

-

GML Visual Set Direction VariableAs you add actions to the workspace, they will be "chained" to the actions above so you can see how the GML Visual code flows, with one action leading to another, and the overview pane shows them in shorthand form and in order of execution:

-

GML Visual chain of actionsSome actions will place code in a separate chain away from the main flow - things like If Variable will create a sub-chain of actions that should occur if the correct conditions are met before continuing on with the main chain:

-

GML Visual side chain of actionsNote that when using actions that can have a side chain block like this, the action will have two areas highlighted for dropping further actions:

-