Jump to content

New to papyrus - need some help


lasere200

Recommended Posts

Thank you very much.

 

Seems to me that the variants of FindClosestReference and FindAllReferences only return "none".

Function checkForJunk()
    while isEquipped
        ObjectReference junkNearme = Game.FindClosestReferenceOfType (TYPETOFIND, 0.0, 0.0, 0.0, distanceToLook)
        if junkNearme != None
                debug.MessageBox(""+junkNearme)
        Utility.wait(1)
        endif
    endwhile
endFunction

set TYPETOFIND to a MiscObject like OilCan01 and no messages around Oil Cans

 

Maybe I'm not using them correctly.

 

EDIT: I got it to work :D I was wrong about FindAllReferences because I did it with FindAllReferencesOfType and a form list. Looking into using the keyword variant now to keep lists small.

 

Thank you so much.

 

It sounds like you may have moved away from this, but just so you're aware, I can tell you why the FindClosestReferenceofType failed.

        ObjectReference junkNearme = Game.FindClosestReferenceOfType (TYPETOFIND, 0.0, 0.0, 0.0, distanceToLook)

That right there points it out. It's not junk near you, it's junk near X = 0, Y = 0, Z = 0. If you wanted near you, you'd do something like this

        ObjectReference junkNearme = Game.FindClosestReferenceOfType (TYPETOFIND, Game.GetPlayer().X, Game.GetPlayer().Y, Game.GetPlayer().Z, distanceToLook)

Anything running from game isn't necessarily pointing at an object reference yet and its not safe to assume it does. So basically at that point it has no idea who 'me' is.

Link to comment
Share on other sites

"If I use JunkNearme.Delete() after Add like in my code above, even though the reference still gets detected where the item used to be, it works."

 

Can you clarify this for me? The object disappears from the shelf but you still see the option to pick it up?

Link to comment
Share on other sites

Well the purpose of the mod is to auto loot. By "it works" i mean a single item is added to my inventory using AddItem and the item disappears from the game world. By the "reference still gets detected" I mean that the array returned by FindAllReferencesWithKeyword has the same lenght near that position where the item/items used to be. I walk away everything is fine, no debug message. I come back to the spot the debug message about the array lenght shows the same lenght (tested with multiple items also).

 

So the ref of a junk item somehow persists in the location it was picked up after the item is gone from the game world. That's what I gather.

Edited by lasere200
Link to comment
Share on other sites

To clarify for people who are curious as well. The way to find an object near you would be through:

Objectreference[] objAr = Game.getPlayer().FindAllReferencesOfType(TYPETOFIND, distanceToLook)
;where distanceToLook is a number of decent size (atleast 500 to get any results really)
if objAr
     int counter = 0
     while counter < objAr.length
          if objAr[i]
               Game.getPlayer().addItem(objAr[i], 1, false)
               objAr[i].delete()
               objAr[i] = none ;breaks persistance
          endif
     endwhile
endIf

This might permanently delete the object ref so any respawnables might disappear but I haven't really tested for that so a little caution

Link to comment
Share on other sites

"objAr = none ;breaks persistance"

 

Thanks. I got busy at work and couldn't dig deeper into it. This is the part I didn't know.

 

If the radius is like sandbox procedure radius, 500 is about the length of a NPC house in Skyrim.

Link to comment
Share on other sites

Yea I'm not sure if they're exactly the same as Skyrim but a comparison of 1000 is around probably about 3ish player lengths. Just a ballpark number but somewhere around that.

Well, around the furthest point from the workshop at spectacle island and being still in the buildable area is close to 14000 if that helps at all. Distance from RR to Sanctuary is something like 5000ish

Link to comment
Share on other sites

I released Auto Loot in January.

Auto Loot is the most configurable auto loot, auto harvest, and auto steal mod for Fallout 4.

  • With Auto Loot, you can automatically loot Ammo, Bodies, Containers, Drinks, Flora, Food, Junk, Medicine, and Valuables.
  • You can automatically send that loot to any settlement, your inventory, or mix and match.
  • Plus, you can configure all aspects of Auto Loot while in the game using a Pip-Boy holotape.
With the in-game menu, you can:
  • Control which loot filters you want activated.
  • Control the auto loot radius for each filter. Every filter has its own radius!
  • Control the auto loot container for each filter. (30 settlements x 9 filters = 270 options!)
  • Control which items are auto looted from bodies and containers.
  • Control whether you always keep loot processed by specific filters.
  • Control whether filters suspend processing while in settlements.
  • Control whether filters ignore ownership. This is Auto Steal!
  • Control whether Auto Steal can trigger combat when you are detected.
  • Control whether Auto Steal loots only owned items, or owned and unowned items.
  • Control whether the Container filter automatically unlocks locked containers
  • Control the rates at which each filter processes the world.

I don't know what you're trying to do, but you can look at my scripts here.

Edited by fireundubh
Link to comment
Share on other sites

 

        ObjectReference junkNearme = Game.FindClosestReferenceOfType (TYPETOFIND, Game.GetPlayer().X, Game.GetPlayer().Y, Game.GetPlayer().Z, distanceToLook)

Anything running from game isn't necessarily pointing at an object reference yet and its not safe to assume it does. So basically at that point it has no idea who 'me' is.

 

 

Is it possible to use this to return the closest container or corpse?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...