• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Item Description onLook Range

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
Hello, could someone please tell me, where can I change item onLook distance?

Like, at this moment it's working like tíbia rl, if you're close to the item you can read description, but if you're far like 3 or 4 sqms away you can't.

I wan't people to see the item description no matter where they are, if 2 sqm, or 7

Thanks in advance <3
 
Try changing the argument in Player
Code:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(3)
 
tried this before, doesn't work '-'

just tested again to confirm and yeah doesn't work, it even removed the description from all items, no matter what distance
 
tried this before, doesn't work '-'

just tested again to confirm and yeah doesn't work, it even removed the description from all items, no matter what distance
Trial and error :p
What is the value of distance?
Place this right under this
Code:
function Player:onLook(thing, position, distance)
Code:
if type(distance) == 'table' then
    print(unpack(distance))
elseif type(distance) == 'number' then
    print(distance)
else
    print(type(distance))
end
So it should look like this
Code:
function Player:onLook(thing, position, distance)
if type(distance) == 'table' then
    print(unpack(distance))
elseif type(distance) == 'number' then
    print(distance)
else
    print(type(distance))
end
local description = "You see " .. thing:getDescription(distance)

Edit: Damn clerical errors.
 
it's printing the correct distance of item

vMHJb1z.png
 
Did you know how to use print?
With print you can add additional arguments to print to the console, just by using a comma ( , )
For instance
Code:
print(distance, type(distance))
The values printed to the console will appear formatted with tabs between each value printed, this will give you an idea which is being executed.

This is just one way to trouble shooting a script & frankly the easiest.
 

didnt worked?

change this:
Code:
if (lookDistance <= 4) {
1263                     if (item) {
1264                         text = &item->getText();
1265                         if (!text->empty()) {
1266                             const std::string& writer = item->getWriter();
1267                             if (!writer.empty()) {
1268                                 s << writer << " wrote";
1269                                 time_t date = item->getDate();
1270                                 if (date != 0) {
1271                                     s << " on " << formatDateShort(date);
1272                                 }
1273                                 s << ": ";
1274                             } else {
1275                                 s << "You read: ";
1276                             }
1277                             s << *text;
1278                         } else {
1279                             s << "Nothing is written on it";
1280                         }
1281                     } else {
1282                         s << "Nothing is written on it";
1283                     }
1284                 } else {
1285                     s << "You are too far away to read it";
1286                 }

to this:

Code:
1263                     if (item) {
1264                         text = &item->getText();
1265                         if (!text->empty()) {
1266                             const std::string& writer = item->getWriter();
1267                             if (!writer.empty()) {
1268                                 s << writer << " wrote";
1269                                 time_t date = item->getDate();
1270                                 if (date != 0) {
1271                                     s << " on " << formatDateShort(date);
1272                                 }
1273                                 s << ": ";
1274                             } else {
1275                                 s << "You read: ";
1276                             }
1277                             s << *text;
1278                         } else {
1279                             s << "Nothing is written on it";
1280                         }
1281                     } else {
1282                         s << "Nothing is written on it";
1283                     }
 
Back
Top