- Joined
- Jul 18, 2019
- Messages
- 2
I'm new around here and I just recently started getting into W3 scripting now that Lua is a thing! I came up with a function that might be useful. If it's not, please just archive this thread and carry on 
Functions like
expect an integer unit id. In JASS, you can pass a 4-character string (such as "hfoo" for a footman) as an integer and Jass converts the string into its corresponding bytes. Lua does not do this automatically and it's more tricky. Here's a short little utility function that does this conversion.
Then you can use it like this
Is there an easier solution that I'm not aware of? If not, I hope this serves useful!

Functions like
Code:
native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
Code:
function getUnitId (idString)
local b1, b2, b3, b4 = string.byte(idString, 1, 4)
return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4
end
Then you can use it like this
Code:
local unit = CreateUnit(GetLocalPlayer(), getUnitId("hfoo"), 0, 0, 0)
Is there an easier solution that I'm not aware of? If not, I hope this serves useful!