Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
global variables
#1
The suggestion is about adding the possibility of creating global variables, I think it would be good to create variables that manage the score, and another to save the value of objects created with tables and be able to access their values from other files in a more comfortable way.
Reply
#2
Hello Marcus.

You are going to introduce global variables in a future update, while I am creating the pong game I am finding it quite difficult to work without global variables.

It may also be me who doesn't know how to work correctly without the globals, in any case I am going to publish little by little the code that I make for the pong game and could you give me some tips so that I can work as comfortably as possible without the globals? global variables.
Reply
#3
I don't like the idea of sharing variables between files, so I have to think some more about it.

You could create "getter" and "setter" functions to read and modify these variables, maybe?

Code:
visible vMyString = "default"

function GetMyString()
   return vMyString
endfunch

function SetMyString(value)
   vMyString = value
endfunc

For a global array/table you probably just need a getter, since tables are of reference type.

Hope this helps!
Reply
#4
Thanks Marcus, that code helps me solve the problem I had. Smile

When I finish Pong I will start another game and in that one I will use lists, we will see if this solution that you have shown me also works with lists.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)