• 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!

OnLook print itemid OTClient

sucibob

Member
Joined
Mar 28, 2017
Messages
128
Reaction score
13
Anybody know where could i edit to print itemid onlook in OTC?

Something like this
Code:
OnLook then
   local item = ???
   local itemid = item:getId()
   print("Item ID:".. itemid)
end
 
for example in gameinterface.lua find this part:
Code:
  -- classic control
  else
    if useThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
      local player = g_game.getLocalPlayer()
      print(""..useThing:getId().."")

Now just right click on item you want to check id
 
for example in gameinterface.lua find this part:
Code:
  -- classic control
  else
    if useThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
      local player = g_game.getLocalPlayer()
      print(""..useThing:getId().."")

Now just right click on item you want to check id

Why this is working:
Code:
function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature)
  local keyboardModifiers = g_keyboard.getModifiers()

  if (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      local player = g_game.getLocalPlayer()
      print(""..useThing:getId().."")
  end

And this not:
Code:
if (mouseButton == MouseLeftButton and mouseButton == MouseRightButton) then
 
Lua:
function customFunction(mousePos, mouseButton)
    if mouseButton ~= MouseRightButton then return end
    --ur code where u use right mouse button
    return true
end

And add otui file
Code:
&onMousePress: modules.game_interface.customFunction
 
Last edited:
Lua:
function customFunction(mousePos, mouseButton)
    if mouseButton ~= MouseRightButton then return end
    --ur code where u use right mouse button
    return true
end

And add otui file
Code:
&onMousePress: modules.game_interface.customFunction

It's not working in gameinterface.. Could you show me how to add in a code full?
Code:
ERROR: failed to load UI from 'gameinterface.otui': cannot have multiple main widgets in otui files
ERROR: Unable to load module 'game_interface': LUA ERROR:
/game_interface/gameinterface.lua:40: attempt to index global 'gameRootPanel' (a nil value)
stack traceback:
   [C]: ?
   /game_interface/gameinterface.lua:40: in function 'init'
   /game_interface/interface.otmod:34:[@onLoad]:1: in main chunk
   [C]: in function 'ensureModuleLoaded'
   /init.lua:46: in main chunk
FATAL ERROR: Unable to load 'game_interface' module
 
Why this is working:
Code:
function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature)
  local keyboardModifiers = g_keyboard.getModifiers()

  if (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      local player = g_game.getLocalPlayer()
      print(""..useThing:getId().."")
  end

And this not:
Code:
if (mouseButton == MouseLeftButton and mouseButton == MouseRightButton) then
Because of LOGIC. There is no detection of clicking both buttons in same time. This event (processMouseAction) executes when you click some mouse button: left or right (anyone also 'middle').
If you check if button is 'right' AND is 'left' it's always FALSE, because button cannot be left and right in same time.
 
Because of LOGIC. There is no detection of clicking both buttons in same time. This event (processMouseAction) executes when you click some mouse button: left or right (anyone also 'middle').
If you check if button is 'right' AND is 'left' it's always FALSE, because button cannot be left and right in same time.
Because of LOGIC. There is no detection of clicking both buttons in same time. This event (processMouseAction) executes when you click some mouse button: left or right (anyone also 'middle').
If you check if button is 'right' AND is 'left' it's always FALSE, because button cannot be left and right in same time.

Thank you gesior!
 
Back
Top