Thread Tools Display Modes
05/11/14, 01:38 AM   #1
CatoTheElder
Join Date: May 2014
Posts: 44
luaindex type

So, after about half dozen posts, I remembered I came here to ask about the luaindex type. I'm about 98% sure someone made that up, and I don't know what in the flying **** I need to pass. I tried the string 'skooma', but it didn't like that ... I know all about arrays, tables, items, and indices, so please don't give me some generic explanation about an index.

Specifically, the lua part of luaindex. Is it looking for an index to correlate to the array/table/object that holds .... the path to the lua compiler?!

If anyone could explain anything about it, I would greatly appreciate it.

Last edited by CatoTheElder : 05/11/14 at 01:42 AM. Reason: clarify my exasperation
  Reply With Quote
05/11/14, 01:51 AM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
It's just a number. I think they call it luaindex becase lua recommends using 1 for first item index in table/string etc. So it's there for you to know to no to pass 'skooma' or -10, just a number in the range 1...n.
  Reply With Quote
05/11/14, 02:17 AM   #3
CatoTheElder
Join Date: May 2014
Posts: 44
So, it should read 'UINT32'. I'm pretty sure someone screwed up id and index on the API page. OTL

WTB edit permissions, PST
  Reply With Quote
05/11/14, 10:34 AM   #4
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
I tend to like using luaindex when I want to reference a number that is converted to a game constant (like player status conditions). It may not be the best name, but in my mind I've always felt a need to distinguish between a pure integer parameter and a very specific subset.
  Reply With Quote
05/11/14, 11:35 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
The term "luaindex" is what was in the original, official docs provided by ZOS.

Yes, it is a number. It is different from "integer" in that it cannot be negative.

It's a wiki - anyone can edit it, so long as you don't screw things up.
  Reply With Quote
05/11/14, 05:31 PM   #6
CatoTheElder
Join Date: May 2014
Posts: 44
Right, didn't realize it was open for edit.

Fair enough for being precise with type definitions, but in a perfect world, the function would take a standard type, run and return properly, even if it is not a global constant, or in a certain subset.

The specific function I was looking at is:
GetGuildId(luaindex index)
Returns: integer guildId

According to my testing, if you pass it a UINT32 in the range of 1..5, it returns what you pass it. If you pass a UINT32 above 5, it returns 0. Which is good, but seems rather impractical. Perhaps it will return 0 if there is no guild assigned to that index? I haven't been able to test that.

Cheers!
Cato
--

Geeky tech details for those interested:
UINT32 is an unsigned integer (positive number with no decimal places), with 32 bits of memory (RAM) allocated. This effectively provides a valid range of integers in the set 1..4294967296 Effects of going outside the range will vary based on the compiler used.

INT32 is a signed integer (negative or positive whole number with no decimal places), with 32 bits of memory allocated, with 1 reserved for the sign. This effectively provides a valid range of integers in the set -2147483648..2147483648

This is an extremely important distinction when working at bit level, as you cannot use 32 bit values, as 1 bit is reserved for the sign.

Quick ex:
(INT32) 1=0x10000000000000000000000000000001
(UINT32) 1=0x00000000000000000000000000000001
  Reply With Quote
05/11/14, 05:50 PM   #7
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Hey, there is no uint32 in lua. There is only one numerical type called number and it is 64bit double precision floating point number.

BTW, 32 bit integer range is signed :-2147483648 to 2147483647, and unsigned: 0 to 4294967295.

Last edited by Harven : 05/11/14 at 05:56 PM.
  Reply With Quote
05/11/14, 06:26 PM   #8
CatoTheElder
Join Date: May 2014
Posts: 44
Originally Posted by Harven View Post
Hey, there is no uint32 in lua. There is only one numerical type called number and it is 64bit double precision floating point number.

BTW, 32 bit integer range is signed :-2147483648 to 2147483647, and unsigned: 0 to 4294967295.
From the LUA reference manual: "There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table."

So, back to my original point - no 'luaindex'. There is no unit32 in lua, but there is in C, which is what we're using the LUA scripting language to interact with. The application is 32 bit, so I wouldn't try passing a 64-bit value to a 32-bit application.

You're right about the integer ranges, good catch. I haven't used 0 as an integer in years. Its far more efficient to type it as a boolean/bit and save the other 31/63 bits
  Reply With Quote
05/11/14, 06:35 PM   #9
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
hmm ESO does have a 64 bit value though if I am understanding the timestamp value correctly.

GetTimeStamp() Returns: id64 timestamp

I may be misunderstanding as that technically could be a 32 bit positive number.
  Reply With Quote
05/11/14, 06:49 PM   #10
CatoTheElder
Join Date: May 2014
Posts: 44
Originally Posted by Xrystal View Post
hmm ESO does have a 64 bit value though if I am understanding the timestamp value correctly.

GetTimeStamp() Returns: id64 timestamp

I may be misunderstanding as that technically could be a 32 bit positive number.
Interesting. I'm not sure what that's about, but I think it would be a good idea to run a trace and find out what is what.
  Reply With Quote
05/11/14, 07:19 PM   #11
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
I use it in my gatherer addon as a unique timestamp as it is unlikely that you can loot from 2 nodes at the same time. Or that two people can gather from the same node in less than a second in the case of imported data.

An example number is : 1399157248.

There isn't a function to extract both the date and time from it within the ESO functions, only the date.
  Reply With Quote
05/12/14, 01:24 AM   #12
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Originally Posted by CatoTheElder View Post
The application is 32 bit, so I wouldn't try passing a 64-bit value to a 32-bit application.
Hey, and why is that? Nothing is stopping you from using 64bit variables in 32bit machine/system/application. Here is some simple C application example:
Code:
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
        unsigned long long integer64bit = 0xffffffffffffffff;
        printf( "%d %llu\n", sizeof(long long), integer64bit );
        return EXIT_SUCCESS;
}
I'm runing it on my 32bit ARMv7 machine, and the output is:
Code:
[harven@fedora-arm test]$ ./bittest
8 18446744073709551615
And in the game on my 64bit Windows 7:
Lua Code:
  1. /script local var = 18446744073709551615 d(var.." type: "..type(var).." "..string.format("%l", var))
gives this:
Code:
1.844674407371e+019 type: number
Luaindex is not a type, it's a clue so we know what numbers we can use. It's like
Code:
typedef double luaindex
you can still pass -1, 3.2 and so one, but the name tells you what the function expects.
  Reply With Quote
05/12/14, 05:19 AM   #13
CatoTheElder
Join Date: May 2014
Posts: 44
Originally Posted by Harven View Post
Hey, and why is that? Nothing is stopping you from using 64bit variables in 32bit machine/system/application. Here is some simple C application example:
Code:
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
        unsigned long long integer64bit = 0xffffffffffffffff;
        printf( "%d %llu\n", sizeof(long long), integer64bit );
        return EXIT_SUCCESS;
}
I'm runing it on my 32bit ARMv7 machine, and the output is:
Code:
[harven@fedora-arm test]$ ./bittest
8 18446744073709551615
And in the game on my 64bit Windows 7:
Lua Code:
  1. /script local var = 18446744073709551615 d(var.." type: "..type(var).." "..string.format("%l", var))
gives this:
Code:
1.844674407371e+019 type: number
Luaindex is not a type, it's a clue so we know what numbers we can use. It's like
Code:
typedef double luaindex
you can still pass -1, 3.2 and so one, but the name tells you what the function expects.
Hahahaha, Fedora on ARM, curious. Big tip of the hat for running that combo!

Anyways, yes... a lot of systems easily work around the "max size" problem these days. memalloc in stdlib has been through a lot of upgrades. I suppose I don't trust them due to headaches from the early days of 64-bit PCs. You can certainly do it, it will probably be okay. I just meant to say, I personally avoid it if at all possible.

I get the point about the 'luaindex', and if Zenimax supplied it, then it is their bad. Perhaps those of you who work in lua more frequently were easier able to understand what they meant. Personally, it confused me far more than it helped. I'm not sure what Zenimax is up to, but every course I've taken on pre-compiler programming uses the following syntax for library listings:

bold is for type
italics is for an example variable
[] are optional parameters

E.x:
GetGuildId(uint32 guildIndex)
Returns: uint32 guildIndex
- 0 if no guild found for index

I purposefully avoided stating "valid range from 1-5", because the purpose if this function seems to be to determine whether or not the input is in the valid range.

Cheers!
  Reply With Quote
05/18/14, 03:45 PM   #14
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by Xrystal View Post
hmm ESO does have a 64 bit value though if I am understanding the timestamp value correctly.

GetTimeStamp() Returns: id64 timestamp

I may be misunderstanding as that technically could be a 32 bit positive number.

No, you are not misunderstanding, CatoTheElder just has no clue what he is talking about.


There is no correlation between the size of a datatype and the memory width size of the architecture. How to do 128bit precision calculation on a 8-bit 8085 cpu was, at least 30 years ago, one of the basic lessons of computer science education.
  Reply With Quote
05/18/14, 03:51 PM   #15
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by CatoTheElder View Post
I get the point about the 'luaindex', and if Zenimax supplied it, then it is their bad. Perhaps those of you who work in lua more frequently were easier able to understand what they meant. Personally, it confused me far more than it helped. I'm not sure what Zenimax is up to, but every course I've taken on pre-compiler programming uses the following syntax for library listings:

bold is for type
italics is for an example variable
[] are optional parameters

E.x:
GetGuildId(uint32 guildIndex)
Returns: uint32 guildIndex
- 0 if no guild found for index



Yes and Microsoft is full of morons because their Win32API documentation dares to have a datatype called HWND or HINSTANCE.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » luaindex type

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off