Jump to content
  • 0

Help me, Setting variable


Cornysz

Question

So i made a script with languange changeable

(this is just example)

a = gg.choice({'Lang 1','Lang 2'})

if a == 1 then goto la1 end

if a == 2 then goto la2 end

::la1::

print('Hi')

 

::la2::

print('Hello')

 

-------

And i wondering if my script like that it will be so long and i need to make the variable and string one by one. Anyone know how to make that but with simple example only 1 variable?

thanks in advance

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • Administrators

Make table and use it.

local a = gg.choice({'Lang 1','Lang 2'})
if a == nil then os.exit() end
local lang = {
	{ -- lang 1
		['hi'] = 'Hi',
	},
	{ -- lang 2
		['hi'] = 'Hello',
	},
}
lang = lang[a]
print(lang['hi'])

 

Link to comment
Share on other sites

Make table and use it.
local a = gg.choice({'Lang 1','Lang 2'})if a == nil then os.exit() endlocal lang = {{ -- lang 1['hi'] = 'Hi',},{ -- lang 2['hi'] = 'Hello',},}lang = lang[a]print(lang['hi'])

 

it take some times to understand that :/ but what is variable lang = lang[a]?
Link to comment
Share on other sites

  • Administrators

I set variable lang to one from choose. In "a" value 1 or 2. So I set lang to need sub table from full table.

_______________________________________________
added 1 minute later

print variable lang and a

print(a, lang)

before and after this line for understand essence.

Link to comment
Share on other sites

I set variable lang to one from choose. In "a" value 1 or 2. So I set lang to need sub table form full.
_______________________________________________ added 1 minute later print variable lang and a
print(a, lang)

before and after this line for understand essence.

and if i click the Lang 1 in that choice what is the output? and i click Lang 2 in that chouce what is the output too?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.