[LUA] Basic JASS based question on creating units in LUA


Previously known as giv_me_rep
Reaction score

decided I'd give crack at writing something in LUA and a little trip back to memory lane on WC3 sounded like a nice idea.

I'm struggling however to just replace a unit selected from a unitgroup!

Would appreciate a set of eyes from the JASS guys, let me know if you spot an issue here.

I think it must be with my local target = GetEnumUnit(), with this in mind i started trying to just create a unit but I couldn't get that going either :S

Unit Id's are taken from WorldEditor, tried with default as well 'hgyr' was tested with in case the issue was that 'h000'is a structure, no dice. Tried with quotationg marks instead of inverted commas but no dice there either. Tried Creating a unit without luck, Destructible without luck. Very very confused...

I put some print lines in there to mark and the last item printed is 6, all units are deleted at the end of this and no new units are created which then tells me that in fact GetEnumUnit() is being detected and in fact the issue is with the unit ID? But then why does the flying machine code not work in testing? I am most confused.

Kind regards

--calls here first

function initSelectTownBuildings()

    --select all units in unit group

    --for each unit in unit group:



    local grpobj = GetUnitsOfPlayerAll(Player(0)) --create unit group of place holder objects

    local unitCount = CountUnitsInGroup(grpobj)


    print("unit Count: "..unitCount)


    ForGroupBJ(grpobj, initPlaceTownBuildings) --run function for each object in group


function initPlaceTownBuildings()


    --if random number == X do action Ax
    --add more stuff later maybe

    local rand = GetRandomInt(1, 1)


    local target = GetEnumUnit() --get the unit pickd


    print("rand: ".. rand)

    --lumbermill scenario

    if (rand == 1) then


        --replace placeholder with lumbermill

        ReplaceUnitBJ(target, 'h000', bj_UNIT_STATE_METHOD_MAXIMUM )



General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    It would suck to spend 400$ on a system that doesn't have the capability you need
  • jonas jonas:
    and it will probably take a couple of tries to get the settings right
  • Varine Varine:
    It would but I can also just make sure I can return them. The system I have works, it's pretty straightforward and I tested it with a camera I have. All it really is is a little cartridge that holds the transparency film and a white light source behind it that projects the image into the lens
  • Varine Varine:
    I'll have to fuck with the light a bit and try some different lighting methods to get color accuracy, but I have IT8 targets for that
  • The Helper The Helper:
    get that color accuracy :)
  • Varine Varine:
    They're really helpful for calibrating things because I'm really colorblind, so I'm not great at doing it by eye
  • Varine Varine:
    Well the long, slow slog of winter has officially begun here
  • Varine Varine:
    I have a bunch of community service I have to do, and I have a feeling there will be a lot of snow shoveling involved now
  • The Helper The Helper:
    don't know why people choose to live in that kind of weather :)
  • Varine Varine:
  • Varine Varine:
    My job is here
  • Varine Varine:
    I was born here man I didn't choose shit
  • Varine Varine:
    And also, I keep moving away and it doesn't get any better. I moved to San Antonio and shit froze there AND we had blackouts
  • tom_mai78101 tom_mai78101:
    I'm back, suffering from severe jet lag.
  • The Helper The Helper:
    Cold is following your ass around Varine - I just dont think I could handle a snowy winter.
  • The Helper The Helper:
    Welcome Back Tom!
  • The Helper The Helper:
    I hear that taking a Melatonin around your normal bedtime can really fix jet lag
  • tom_mai78101 tom_mai78101:
    Yeah, I also heard about that as well. I think I'm good. I'm just lucky it's the weekend so I have some time to readjust.
  • Varine Varine:
    It was a fucking blizzard today, shoveling was an effort in futility.
  • Varine Varine:
    Melatonin gives me nightmares
  • Varine Varine:
    They had me shoveling out the parking lot for the jail. Fucking pointless, they need a blow.
  • Varine Varine:
    Well they gave me a snow blower but it was too wet to do much with with other than compact everything. Oh well, the cop cars can get into there now when they arrest people I guess

    The Helper Discord

    Staff online

    Members online


    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.