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

WildTurkey

Previously known as giv_me_rep
Hello,


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

Code:
--calls here first

function initSelectTownBuildings()

    --select all units in unit group

    --for each unit in unit group:

  

    print("1")

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

    local unitCount = CountUnitsInGroup(grpobj)

    print("2")

    print("unit Count: "..unitCount)

  

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

end


function initPlaceTownBuildings()

    print("3")

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

    local rand = GetRandomInt(1, 1)

    print("4")

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

    print("5")

    print("rand: ".. rand)

    --lumbermill scenario

    if (rand == 1) then

        print("6")

        --replace placeholder with lumbermill

        ReplaceUnitBJ(target, 'h000', bj_UNIT_STATE_METHOD_MAXIMUM )

        print("7")
        --CODE DOES NOT REACH THIS POINT!

    end

end
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is possible to automate it so that instead of moving to Archive if it has the Science, technology or sci tech tag that it gets archived there instead. I am considering a new Weird News Tag
  • tom_mai78101 tom_mai78101:
    Please do. I'll try to tag the news appropriately when I get the chance.
  • The Helper The Helper:
    The new Discourse forum software we are moving to next does alot with the tags and also hashtags
  • The Helper The Helper:
    OK I found the source of your burrito post stuff it is from Reddit and possibly a facebook post too but definitely reddit
  • The Helper The Helper:
    Happy Monday!
  • The Helper The Helper:
    Happy Tuesday :)
  • Blackveiled Blackveiled:
    Happy Tuesday
  • The Helper The Helper:
    Blackveiled! What is up?
  • The Helper The Helper:
    I saw XXXConan on here the other day I dont know if you remember him
  • The Helper The Helper:
    blasts from the past
  • Blackveiled Blackveiled:
    I remember him, buncha old faces
  • jonas jonas:
    He's a software engineer at a hiring platform now I think
  • The Helper The Helper:
    I wanna know if his mom is still single LOL
  • tom_mai78101 tom_mai78101:
    I need context.
    +1
  • The Helper The Helper:
    Back in the day conan was a young one and his mom was single and I used to tease him that I was going to date his mom and be his daddy - yeah sounds bad now but it was funny at the time
  • The Helper The Helper:
    his mom is my age
  • The Helper The Helper:
    i know right it was pretty funny
  • thewrongvine thewrongvine:
    its pretty funny
    +1
  • tom_mai78101 tom_mai78101:
    Thanks for the context.
    +1
  • The Helper The Helper:
    Happy Hump Day!!!
  • Blackveiled Blackveiled:
    TH old fart gotta have a beer with me one of these days
  • The Helper The Helper:
    I am down anytime Blackveiled
  • Blackveiled Blackveiled:
    count on it then cause you don't live that far from me hah
  • The Helper The Helper:
    really that is cool! I am in Houston in the 77079 area

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top