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

OTCV8 How to create working top menu icon

SixNine

Active Member
Joined
Dec 12, 2018
Messages
452
Reaction score
41
Hello how can i make working icon on top right corner, when you click on it, it sends this lua function.
player:showSystem()
 
Why don't you just look at default modules that are adding these icons and use that code?
 
Why don't you just look at default modules that are adding these icons and use that code?
They look to complicated and each one of them are different and have like million of code parts linked to each line. Like game_shop it needs to add code in onStoreInit like (createShop()) when i dont even have callback like that, so wtf.
 
They look to complicated and each one of them are different and have like million of code parts linked to each line. Like game_shop it needs to add code in onStoreInit like (createShop()) when i dont even have callback like that, so wtf.

As far as i have investigated by the suggestion of the other user, it should be something like this:
Lua:
skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills'), '/images/topbuttons/skills', toggle, false, 1)
skillsButton:setOn(true)

There are another functions using this registrered variable on skills.lua at modules
 
As far as i have investigated by the suggestion of the other user, it should be something like this:
Lua:
skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills'), '/images/topbuttons/skills', toggle, false, 1)
skillsButton:setOn(true)

There are another functions using this registrered variable on skills.lua at modules
I dont see how this should even work, it just creates a buttom with zero functionality
 
I dont see how this should even work, it just creates a buttom with zero functionality
Toggle is the callback that you should change into the callback of your window, this is the documentation for the function that i found lurking on the files:
Lua:
function addRightGameToggleButton(id, description, icon, callback, front, index)
 
Toggle is the callback that you should change into the callback of your window, this is the documentation for the function that i found lurking on the files:
Lua:
function addRightGameToggleButton(id, description, icon, callback, front, index)
so if i have this function or im not even sure if its right function to use
Lua:
function create()
  if window then
    return
  end

  window = g_ui.displayUI("crafting")
  window:hide()

  categories = window:getChildById("categories")
  craftPanel = window:getChildById("craftPanel")
  itemsList = window:getChildById("itemsList")

  local vocDrop = window:recursiveGetChildById("vocations")
  if vocDrop:getOptionsCount() == 0 then
    vocDrop.onOptionChange = onVocationChange
    for i = 1, #vocations do
      vocDrop:addOption(vocations[i], i)
    end
    vocDrop:setCurrentIndex(1)
  end
  vocDrop.menuHeight = 125
  vocDrop.menuScroll = false

  local protocolGame = g_game.getProtocolGame()
  if protocolGame then
    protocolGame:sendExtendedOpcode(CODE, json.encode({action = "fetch"}))
  end
end

it should be

skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills'), '/images/topbuttons/skills', create, false, 1)
skillsButton:setOn(true)

but its false because i tried like this, it creates a button but nothing happens it doesnt call the function
 
so if i have this function or im not even sure if its right function to use
Lua:
function create()
  if window then
    return
  end

  window = g_ui.displayUI("crafting")
  window:hide()

  categories = window:getChildById("categories")
  craftPanel = window:getChildById("craftPanel")
  itemsList = window:getChildById("itemsList")

  local vocDrop = window:recursiveGetChildById("vocations")
  if vocDrop:getOptionsCount() == 0 then
    vocDrop.onOptionChange = onVocationChange
    for i = 1, #vocations do
      vocDrop:addOption(vocations[i], i)
    end
    vocDrop:setCurrentIndex(1)
  end
  vocDrop.menuHeight = 125
  vocDrop.menuScroll = false

  local protocolGame = g_game.getProtocolGame()
  if protocolGame then
    protocolGame:sendExtendedOpcode(CODE, json.encode({action = "fetch"}))
  end
end

it should be

skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills'), '/images/topbuttons/skills', create, false, 1)
skillsButton:setOn(true)

but its false because i tried like this, it creates a button but nothing happens it doesnt call the function
This code is from my crafting module. Why don't you DM me on discord?
 
Back
Top