Right now, I want to make an array variable called deckOfCards. Since a deck of cards is pretty static, I want to make it a global variable that any minigame I create can access.
Here is the one example of code that would call this deckOfCards variable:
Code: Select all
label game:
...
init python:
...
for k in deckOfCards:
...
First I tried
Code: Select all
default deckOfCards = ['A', 'B', 'C','D','E']
I tried replacing
Code: Select all
default
Code: Select all
define
What is the difference between both of these? What happens if I don't include either and just do deckOfcards = X?
I know that when you create a variable inside a function, it can only be used inside of that function, unless you make it a global variable. Global variable can be used in all functions right? Are "labels" and "screens" functions? If you create variable inside of a label or a screen, can they be used outside of that label or screen?
I'm assuming not to both because
Code: Select all
init python:
global deckOfCards
deckOfCards = ['A', 'B']
How come you can't define a global variable in the same line that you declare it?
Is there any difference between putting your code after a python: and just putting a dollar sign before each line? Init just makes whatever code is in the block run before all other code right? You can do init with python or without? I'm a little confused about all this stuff.