HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Help with Lists  (Read 1115 times)

Arlohian

  • General Accounts
  • *
  • Posts: 43
    • View Profile
[Resolved] Help with Lists
« on: Sep 15, 12, 05:33:01 PM »

Hi again, tired of Guild Wars 2 already :/

Anyway...

I've got a question about lists, yes I've been on the wiki page :)

Description:
When I try to remove ex. a noderef from a list, does it remove it from the list, or does it destroy the object the noderef is pointing at?

At this point it seems it destroys the entire object, since my targeting and tabbing functions for some reason somtimes delete the creature and causing a nice error, that there is no creature.

What i want to do is just remove the noderef from the list, without destroying the object its pointing at. Is this how it works or?

example of how I'm doing this
Code: (hsl) [Select]
targets as list of noderef = GetTargets()
n as integer = 1

if targets.lenght != 0
  foreach t in targets
    if t = GetClickTarget()
      remove targets at n destroy
    .
    n = n + 1
  .
.
« Last Edit: Sep 26, 12, 09:41:16 AM by HE-Cooper »
Logged
Fledgling programmer

Lunchbox

  • World Owners
  • ****
  • Posts: 136
    • View Profile
    • BrandNGames
Re: Help with Lists
« Reply #1 on: Sep 15, 12, 05:39:59 PM »

Thats how I did it. In my spawner I add mobs to my list and when they die I use this line to remove them from the list. With my spawner code it was tricky as I had to check to see if the target was dead then remove it. But this line is what I use to remove the noderef from the list.
Code: [Select]
remove me.VD_mobNodeList at foundAt destroy

Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Help with Lists
« Reply #2 on: Sep 15, 12, 06:20:49 PM »

Hi again, tired of Guild Wars 2 already :/

Anyway...

I've got a question about lists, yes I've been on the wiki page :)

Description:
When I try to remove ex. a noderef from a list, does it remove it from the list, or does it destroy the object the noderef is pointing at?

At this point it seems it destroys the entire object, since my targeting and tabbing functions for some reason somtimes delete the creature and causing a nice error, that there is no creature.

What i want to do is just remove the noderef from the list, without destroying the object its pointing at. Is this how it works or?

example of how I'm doing this
Code: (hsl) [Select]
targets as list of noderef = GetTargets()
n as integer = 1

if targets.lenght != 0
  foreach t in targets
    if t = GetClickTarget()
      remove targets at n destroy
    .
    n = n + 1
  .
.
To not destroy the object the noderef is pointing at, you can just remove "destroy", or replace "destroy" with "keep"
Code: (hsl) [Select]
targets as list of noderef = GetTargets()
n as integer = 1

if targets.lenght != 0
  foreach t in targets
    if t = GetClickTarget()
      remove targets at n keep
    .
    n = n + 1
  .
.
Logged

Arlohian

  • General Accounts
  • *
  • Posts: 43
    • View Profile
Re: Help with Lists
« Reply #3 on: Sep 16, 12, 08:07:28 AM »

Thanks!

"remove targets at n keep" woks perfect. No more mysteriously deleting mobs when i AOE dead ones :P
Good to know that i can delete them through the list if i would need that, less code.

Sorta misunderstood how lists worked, haven't used them prior to writing in HSL.
Logged
Fledgling programmer

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Help with Lists
« Reply #4 on: Sep 16, 12, 03:53:58 PM »

That's curious.  HeroSense is working for you, correct?  In the script editor, after typing the 'n' at the end of the remove line and pressing space, the HeroSense should pop up with the options of destroy and keep.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Arlohian

  • General Accounts
  • *
  • Posts: 43
    • View Profile
Re: Help with Lists
« Reply #5 on: Sep 17, 12, 03:38:04 AM »

Yes HeroSense is working perfectly fine, it just wasnt logical for me at first :P To remove from x at y place and keep it...? so youre not removing it? thats how i thought of it first.

Havnt used lists before since ive only coded in C for like... half a year or so (at university) before starting in HSL, C doesnt nativly have lists, classes nor strings, so had a few concepts to learn, and still learning :)
« Last Edit: Sep 17, 12, 03:40:37 AM by Arlohian »
Logged
Fledgling programmer