Jump to content
  • 0

Creating multiple switch


Peter_Aquino

Question

1 answer to this question

Recommended Posts

Posted
17 hours ago, Peter_Aquino said:

How can I created multiple switch at least four("4")

Hi @Peter_Aquino, what exactly "Switch" you're refering here? Is it some kind of switch statement?

switch = {
	[1] = 'this is first',
	[2] = 'this is second',
	[3] = 'this is third',
	[4] = 'this is fourth'
}
choice = tonumber(gg.prompt({"Enter Choices"},{0},{"number"})[1])

if choice == nil then
	print('Invalid Choice, exitting..')
	os.exit()
end

# Example Use Case 1
print(switch[choice])

# Example Use Case 2
if switch[1] == 'this is first' then
	print('True')
else
	print('False')
end

 

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.