Predefined unit returns (null) with registered to system

Embrace_It

New Member
Reaction score
9
Yet another problem...This is a weird one though.

I have a system that can only register heroes.
I created a custom hero, and to further test the system I created another hero by copying the data from the first hero. I added the following debug message to the function, that checks whether or not the unit provided is a hero:

JASS:

call GetUnitName(whichhero)


This outputs "(null)", which doesnt make sense. I call the function with gg_unit_O001_0009 as the unit argument. This works fine for hero 1, but not for unit 2. I then tried to create a hero from scratch, but it didnt work either.

The function tests like this:

JASS:

if not IsUnitType(whichhero, UNIT_TYPE_HERO) then
    call PassError("Must register talents for heroes only")
    return
else
    set id = GetHandleId(whichhero)
endif


Unless someone has an explain for this based on the above, I wont post the code for the system if it isnt necessary.

Thanks! :)
 
Perhaps the string table is not initialised (yet).

What do you mean?

I forgot to mention that when I save the map, it sometimes pops 1 error message: "Undeclared variable gg_unit_O001_0009". It seems this predefined global variable is either not created, or not created properly.
 
It is a preplaced unit right? Maybe, just maybe you have deleted this unit which means it doesn't exist anymore. The name of an unit that doesn't exist doesn't exist either^^
Maybe there is a problem with the initialization of the variable "whichhero". Where and how do you initialize it?
 
Even if you can guess the variable name of preplaced unit, you have to select them with a gui condition/action (one time is enough and can you can delete the gui stuff after the selection), or the variable won't be created at all.
As simple and annoying as that.
 
I usually create a trigger, make an action for killing a unit, select the unit I want and "Convert to Custom Text" it, so that I can see the preplaced unit's id/variable.

I have not deleted the unit.
 
Solved!....Somewhat...

I noticed that there HAS to be a trigger of some kind using the preplaced unit's id (fx. gg_unit_O001_0009) for this to work. If you deleted the trigger(s) it doesnt work since the values are set to null. In this case I have a trigger that increases all heroes' levels in the map when Player 1 enters "-lvlup"...

If someone has an alternative, please show me :)

As always, thanks for the help/advice!
 
May I ask why you have preplaced heroes? If users pick a hero you could put them in a
JASS:
unit array heroes

and do stuff with them when you need to
doing things for one player could be done like this
JASS:
local integer i = 0
loop
  if GetOwningPlayer(heroes<i>) == thePlayer then
    //dostuff
  endif
  set i = i+1
  exitwhen i==MAXHEROES
endloop</i>

//untested
 
@ Prozix: True, but this is a map for testing purposes, so I have preplaced units for testing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top