Jump to content

c_selectnear() doesn't return anything

  • Pending

Hello, I am not sure if it is intended to be that way. However this function in consolecommands.lua returns null and it is not usefull.

function c_selectnear(prefab, rad)
    local player = ConsoleCommandPlayer()
    local x,y,z = player.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x,y,z, rad or 30)
    local closest = nil
    local closeness = nil
    for k,v in pairs(ents) do
            print("found", v.prefab)
        if v.prefab == prefab then
            print("found", v.prefab)
            if closest == nil or player:GetDistanceSqToInst(v) < closeness then
                closest = v
                closeness = player:GetDistanceSqToInst(v)
    if closest then

I think there should be `retrun c_select(closest)`.

Steps to Reproduce

It is nothing serious tho. :) 

User Feedback


Nvm, I looked at the file myself as I though that the game might have handled the console in one fashion instead of another but I was wrong.

However, if you actually look at how c_select() is handled, it's selection actually sticks to a global variable that can be accessed using c_sel().

So you can call c_selectnear() and then c_sel():... to perform a command on the object.

I do feel that this should still have the return statement though so that it can be used more directly.

Edited by oblivioncth
  • Like 1

Share this comment

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...