PDA

View Full Version : Any suggestion how to determine object level *outdoors*?


Jasana_BugBreeder
18th Jan 2009, 11:26 AM
By "level", I mean floor the object is on (counting foundations as separate floors).

For indoor objects, it's supposedly done via [global 0x034E] Get in Temp 0 - Object Level. The problem is, "level" is a property of room, not object - and all outdoor objects are considered to be located in the same room, #0, with level=0 :|

Any suggestions? Trying to put it short, I want to select next object to interact with, and objects on the same level should be preferred. If nothing help, I probably could live with just [global 0x0364] Distance - Objects <= X tiles apart?, but I'm not certain yet how it counts distance for objects from different floors.

tunaisafish
27th Feb 2009, 10:19 AM
Sorry, I didn't see this message before. I hope this info is still of use.

Try calling the LUA 'CompareObjectLevels(ObID1, ObID2)'.

I know it takes 2 objects ID's as lua parameters, and that it compares the levels and (I think) only returns true if they are the same.
It also looks like it sets T0 and T1 to the levels of the 2 objects, but not sure if that is only when it returns true.

There's also GetObjectLocation(ObID)
That gives you X & Y coords in T0 & T1, and the level in T2
Returns true always, and sets T0 & T1 to -1 if it failed.

While the internals of both lua's should be NL+ compatible, it doesn't look like EA included them with NL.

So...

This is a general purpose script that you (should?) be able to use with any NL+ compatible object.

Create a text resource in your private object with instance 0x0130
In the first row type a function name, like 'real_level_in_T0'.
Paste this code into the 'description' field.


--[[
real_level_in_T0( ObjectID )

Returns false on an error and sets T0 to -100
Otherwise, returns true and sets T0 to the real objects level
]]
local res, t0, ob = false, -100, GetPrimitiveParameter(0)

if (GlobalObjManager:verifyObjectId(ob) ~= 0) then
local x,y,l = nWorld.GetObjectTile(ob)
if (x ~= nil) then
t0 = l
res = true
end
end

SetTemp(0, t0)
SetScriptReturnValue(res)


In your private BHAV. Set the OpCode to 0x007E, and the NodeValue to 0
If the object to test is already in the StackOb, use these Operands...
'300101000A000A000007000007000000'
(Otherwise edit the bold bits to suit your data-owner/value)

J. M. Pescado
27th Feb 2009, 02:19 PM
For indoor objects, it's supposedly done via [global 0x034E] Get in Temp 0 - Object Level. The problem is, "level" is a property of room, not object - and all outdoor objects are considered to be located in the same room, #0, with level=0 :|This is, strictly speaking, not quite true. All objects that are in room #0, I.E., have a contiguous, unwalled connection to street, are room 0, level 0, but not ALL outdoor objects are in room 0. This issue can be resolved by simple construction techniques, such as using floor dividers to create a "box" that isolates a given outdoor area, such as a balcony or roof, from room 0. If the Tuna approach fails to produce better results, or you need this to work in Uni/Base, consider revising your construction techniques instead of trying to generate a hack around it.