diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm index edd41c570..6c5314f5e 100644 --- a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm +++ b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm @@ -42,18 +42,61 @@
The page on self contains a section on When 'self' changes.
-This section will describe those cases in relation to how other changes:
+This section describes those cases in relation to how other changes:
value = 40;
+
+ var _struct = {
+ value : 99
+ }
+
+ with (_struct)
+ {
+ show_debug_message(other.value); // Prints 40
+ }
+
value = 40;
+
+ var _struct = instance_create_depth(0, 0, 0, Object2, {
+ value : 99,
+ func : function () {
+ return other.value;
+ }
+ });
+
+ var _func = _struct.func;
+
+ show_message(_func()); // Prints 40
+
value = 40;
+
+ item = function () constructor {
+ value = 99;
+
+ copied_value = other.value;
+ }
+
+ my_item = new item();
+ show_debug_message(my_item.copied_value); // Prints 40
+
In previous versions of GameMaker other only changed in the following cases:
This behaviour can be enabled by the Legacy Other Behaviour game option.
In this example you can see that we have a local variable called val and we want it to set the instance variable with the same name in the newly created object instance. To identify the instance variable correctly and tell GameMaker to set it in the instance calling the code block, we use the self keyword.
self is used in the same way with structs to reference member variables of the struct. It can also be used within constructor functions to reference the struct being generated from the constructor.
+Due to compatibility reasons, converting self into a string will return -1.
Within an event, the current self will change in the following situations:
+Within an event or script, the current self will change in the following situations:
value = 40;
+
+ var _struct = instance_create_depth(0, 0, 0, Object2, {
+ value : 99,
+ func : function () {
+ return self.value;
+ }
+ });
+
+ var _func = _struct.func;
+
+ show_message(_func()); // Prints 99
+
value = 40;
+
+ item = function () constructor {
+ value = 99;
+
+ copied_value = self.value;
+ }
+
+ my_item = new item();
+ show_debug_message(my_item.copied_value); // Prints 99
+
In all of these cases, when self changes to a new scope, other will be set to be the previous scope. The only exception is when a bound constructor method is called. This is described more in When 'other' changes.
diff --git a/Manual/contents/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/load_csv.htm b/Manual/contents/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/load_csv.htm index fc6e8dc20..4a6d087a7 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/load_csv.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/File_Handling/Encoding_And_Hashing/load_csv.htm @@ -1,16 +1,17 @@ - - + + +
file_grid = load_csv("spreadsheet.csv");
- var ww = ds_grid_width(file_grid);
- var hh = ds_grid_height(file_grid);
- var xx = 32;
- var yy = 32;
- for (var i = 0; i < ww; i++;)
- {
- for (var j = 0; j < hh; j++;)
- {
- draw_text(xx, yy, file_grid[# i, j]);
- yy += 32;
- }
- yy = 32;
- xx += 32;
+
file_grid = load_csv("spreadsheet.csv");
+ var ww = ds_grid_width(file_grid);
+ var hh = ds_grid_height(file_grid);
+ var xx = 32;
+ var yy = 32;
+ for (var i = 0; i < ww; i++;)
+ {
+ for (var j = 0; j < hh; j++;)
+ {
+ draw_text(xx, yy, file_grid[# i, j]);
+ yy += 32;
+ }
+ yy = 32;
+ xx += 32;
}
The above code will open the given CSV file and store the returned DS grid in the variable "file_grid". This grid is then parsed in a couple of for lops and the contents drawn to the screen.
+The above code will open the given CSV file and store the returned DS grid in the variable "file_grid". This grid is then parsed in a couple of for loops and the contents drawn to the screen.
@@ -74,5 +75,5 @@
When using raw TCP networking, multiple packets sent by one client may be received as a single packet by the receiving client, and the opposite may also happen where a single packet is split into multiple packets. Non-raw networking functions prevent this from happening as GameMaker inserts headers into each packet, allowing the receiving GameMaker client to separate or combine incoming packets to represent them as they were sent.
When using raw TCP functions, it will fall on the game to read the incoming packets and separate/combine them as they were sent.
-When using UDP or WebSockets, packets will be delivered in the form that they were sent, so using the non-raw functions for these protocols only adds unnecessary overhead.
+When using UDP or WebSockets, packets will be delivered in the form that they were sent. Using the non-raw functions for these protocols only adds unnecessary overhead.
This function sends data over the network using UDP to a server.
-The function takes the Network Socket ID to connect through, the URL to connect to and the port to use. You must then supply the Buffer which contains the data to be sent (for more information on buffers see Reference - Buffers) and finally the size (in bytes) of the data. The function returns the number of bytes of data sent, or a number less than 0 if the send has failed.
-The data sent is not formatted by GameMaker in any way and the receiving devices will get the data as a stream which means you will have to handle it yourself.
+The function takes the Network Socket ID to connect through, the URL to connect to and the port to use. You must then supply the Buffer which contains the data to be sent (for more information on buffers see Reference - Buffers) and finally the size (in bytes) of the data. The function returns the number of bytes of data sent, or a number less than 0 if the send has failed.
+The data sent is not formatted by GameMaker in any way and the receiving devices will get the packets in the exact form they were sent in.
UDP is "connectionless" in that you don't actually do a connect, you just send a packet directly to an IP, and the server gets incoming data from an IP address and has to deal with it "as is".
NOTE This function will not work when used in a project running on the HTML5 target, and neither will HTML5 projects be able to receive UDP.
network_send_udp_raw(sock, "www.macsweeneygames.com", 6510, buff, buffer_tell(buff));
@@ -74,7 +74,7 @@