Skip to content

Commit 9817bc7

Browse files
committed
Update README to clarify boolean conversion
1 parent e5ec178 commit 9817bc7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ Python | GML
2929
--------------|-----------------------
3030
`int` | `real`
3131
`float` | `real`
32-
`bool` | `real` (`true`/`false`)
32+
`bool` | `bool`*
3333
`str` | `string`
3434
`list` | `array`
3535
`dict` | `struct`
3636
`None` | `pointer_null`
3737
_(exception)_ | `undefined`
3838

39+
\*In order for booleans to be transmitted properly to Python, you must explicitly convert them with the `bool()` function in GML. See [Limitations](#GameMaker_data_types) for details.
40+
3941
Nested arrays/structs in the arguments are supported and will be correctly transmitted to Python as nested lists/dicts. In the same fashion, returning those structures from the called function will also convert it to arrays and structs on the way back to GML.
4042

4143

@@ -119,7 +121,7 @@ var result = python_call_function("builtins", "sorted", [[4, 2, 3, 1, 5]], {reve
119121
show_debug_message(result); // [ 5,4,3,2,1 ]
120122
```
121123

122-
> It's recommended to call `bool()` on any boolean that you want to pass as an argument. Due to the way GameMaker handles booleans, Python will receive a `float` instead of a `bool` if you don't do this, which is not desirable in many cases. Read more about that in [Limitations](#Limitations).
124+
> It's recommended to call `bool()` on any boolean that you want to pass as an argument. Due to the way GameMaker handles booleans, Python will receive a `float` instead of a `bool` if you don't do this, which is not desirable in many cases. Read more about that in [Limitations](#GameMaker_data_types).
123125
124126
Any exception that occurs in the Python side will throw a GameMaker error containing the exception message and traceback, which may be caught by wrapping the call in a `try`/`catch` block:
125127

0 commit comments

Comments
 (0)