Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Recommended Posts

I started playing around with the networking in Leadwerks and found that I needed enums. So I wrote a function that will allow you to enumerate a table.


function enumerate(array,indexstart) -- indexstart is optional
	if array == nil then return nil end
	local array2 = {}
	local count = tonumber(indexstart) ~= nil and tonumber(indexstart) or 0
	for key,value in pairs(array) do
		array2[value] = count
		count = count + 1		
	return array2

This will take an array of strings and output a named table array.


enum_netchat =  enumerate({


This is the simplest way to make an enum

  • Upvote 2
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...