• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Save Item-type to hashtable in Lua?

Level 13
Joined
Jul 12, 2018
Messages
510
Hi,
So according to these threads:

.. you can store an item type in integer form in Jass using the following:

Custom script: set udg_integer = udg_itemType

My question is what does this look like in Lua?

I'm sure the answer is contained in one of the Lua tutorials but those turn into Greek two words into each sentence to me as a Gui user who converted for someone else to install a Lua system in his map.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,517
I know we talked about this already in private but for the sake of others...

Jass:
  • Custom script: set udg_integer = udg_itemType
  • Hashtable - Save integer as 0 of 0 in (Last created hashtable).
Lua:
  • Custom script: udg_integer = udg_itemType
  • Hashtable - Save integer as 0 of 0 in (Last created hashtable).
A global variable needs to have the prefix _udg when written inside of code. That's how the game is able to discern between:
Variables created in code AND variables created in GUI (the standard method that you use).

Custom script IS code.

No two GUI variables or two coded variables can share the same name, HOWEVER, you can have a GUI variable and a coded variable with the same name.

udg probably stands for User Declared Global if that helps.

Lua shaves off the need for the words "set" and "call" but other than that the syntax will remain mostly the same especially if you're writing in Custom script.
 
Last edited:
Top