Discord
Login
Community
DARK THEME

[noob] code outside main functions. microscript

so yes. i write something smol. i wanted to make global variables outside of init, draw and update functions. will it work?

Yes 😁 Actually, any variables you make that are not marked with local, are global variables.

Yes.

g=999

init = function()
end

update = function()
  g += 1
end

draw = function()
  screen.clear("rgb(0,0,0)")
  screen.drawText(g, 0, 0, 12, "rgb(255,0,0)")
 
end

But don't use the variable name 'global'!

fine i wont. lool. was using JS for some time and phyton. but its good to learn new things too :'D thx anyways <3

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community