Problems with GetNearbyObjects

Discussion about Mods for Prison Architect

Moderator: NBJeff

ProgSys
level0
Posts: 3
Joined: Sat Oct 04, 2014 4:57 pm

Problems with GetNearbyObjects

Postby ProgSys » Sat Oct 04, 2014 7:11 pm

Hi everyone,

It is maybe a dump question, but I don't understand what "TypeName" means in "Object.GetNearbyObjects( TypeName, SearchDistance )".
I looked through the Lua page and tried values like "Object" or "People", but nothing seems to work.

Here is a piece of my code:

Code: Select all

   local found = Object.GetNearbyObjects( "People", 20 );
   local size = table.getn(found);
   Game.DebugOut(size);

   for k, v in pairs(found) do
   Game.DebugOut(k);
   Game.DebugOut(v);
   end

-- [EDIT] Working code:
   local objectTypes = {"Guard","Prisoner" }
   for i,objectType in ipairs( objectTypes ) do
      local found = Object.GetNearbyObjects( objectType, 4 );
      for id, distance in pairs(found) do
         Game.DebugOut("Found:");
         Game.DebugOut(id);
      end
   end


Also I have problems with the Debug window, "DebugOut" does not open it. It only opens if a error happens. Is there a button to open it?

Thank you for your help!
Last edited by ProgSys on Mon Oct 06, 2014 10:05 pm, edited 4 times in total.
learn_more
level1
level1
Posts: 36
Joined: Sun Sep 07, 2014 9:18 pm

Re: Problems with GetNearbyObjects

Postby learn_more » Sat Oct 04, 2014 11:34 pm

DebugOut prints either to the debug.txt or the windows debug output.

use DebugView : http://technet.microsoft.com/en-us/sysi ... 96647.aspx or logfusion: http://www.logfusion.ca/ to view debug output.

and no, the script debugger only opens on a script error


ps: you can use print as well, they redirected DebugOut to that.
ProgSys
level0
Posts: 3
Joined: Sat Oct 04, 2014 4:57 pm

Re: Problems with GetNearbyObjects

Postby ProgSys » Sun Oct 05, 2014 10:55 am

Well DebugOut does print in the game console:
Image
but it does not open the console, even thoght the description of the function inside "lua_function_list.txt" reads:
Game.DebugOut( Message )
Prints a debug message to the script debugger window. Opens the window if it is not yet opened.
N.B. As this functions opens a debug window, you should only use this function for testing purposes
and remove any calls before publishing your mod.

Only a error seams to open the console. So I thought there is maybe a hidden button to open it.

I tried to use print(), but it throws a Runtime Error.
I will try out DebugView.
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: Problems with GetNearbyObjects

Postby elDiablo » Mon Oct 06, 2014 5:59 pm

Sorry, my bad.

TypeName is the Object type's name to get. This is the name given in the Object list from materials.txt. Things like, "Workman", "Toilet", "Visitor", etc. You can see the full list of default item names in the ObjectRequired section of the Material mod schema at http://devwiki.introversion.co.uk/pa/in ... /ModSchema but can also use your own added names. GetNearbyObjects will be improved in later versions (probably a new function) to allow you to search by properties (GetNearbyObjectsWithProperties or something) as well, as searching for all entities at the moment is a bit of a hassle (you will need to search for all entity subtypes, such as "Prisoner", "Medic", "Administrator", etc.).

The DebugWindow isn't working as intended. We'll look at that as well.
ProgSys
level0
Posts: 3
Joined: Sat Oct 04, 2014 4:57 pm

Re: Problems with GetNearbyObjects

Postby ProgSys » Mon Oct 06, 2014 9:58 pm

Thank you! You helped me a lot :D It would be nice to have a function, which prints out all properties a object has and the ability to put orders into the Work Queue, like "Search Object".

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 10 guests