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

OTClient Shop Module

_Aion_

Nothing Else
Joined
Jan 19, 2010
Messages
400
Solutions
4
Reaction score
10
Location
Jequie,Bahia,Brazil
Hello. Someone can help solve this problem?
I'm trying create a market with "diamond". But i have this error.
unknown.png


this is my init from shop.lua
Code:
function init()
  connect(g_game, { onGameEnd = hide })
  connect(g_game, 'onTextMessage', onConfirmBought) 


  shopWindow = g_ui.displayUI('shop', modules.game_interface.getRootPanel())
  shopButton = modules.client_topmenu.addRightGameToggleButton('shopButton', tr('Shop'), '/images/topbuttons/bot', toggle, false, 99999)
  playerEmeralds = shopWindow:recursiveGetChildById('emeraldsLabel')
  offerSearch = shopWindow:recursiveGetChildById('searchText')
  shopButton:setOn(false)
  shopWindow:hide()

  shopTabBar = shopWindow:recursiveGetChildById('shopTabBar')
  shopTabBar:setContentWidget(shopWindow:recursiveGetChildById('shopTabContent'))
  shopTabBar.onTabChange = onTabChange

  marketPanel = g_ui.loadUI('market')
  shopTabBar:addTab('', marketPanel, '/images/game/shop/market')

  outfitsPanel = g_ui.loadUI('outfits')
  shopTabBar:addTab('', outfitsPanel, '/images/game/shop/outfits')

  addonsPanel = g_ui.loadUI('addons')
  shopTabBar:addTab('', addonsPanel, '/images/game/shop/addons')

  clansPanel = g_ui.loadUI('clans')
  shopTabBar:addTab('', clansPanel, '/images/game/shop/clans')

  shopTabBar:addButton('', function() g_game.talk('Buy Diamonds') end, '/images/game/shop/buy_emeralds')
end

and this my shop.otui
Code:
ClanWindow < MainWindow
  size: 210 100
  @onEscape: modules.game_shop.destroyClanWindow()

  Label
    text: Rank:
    width: 38
    anchors.top: parent.top
    anchors.left: parent.left
    margin-top: 2

  SpinBox
    id: spinBox
    step: 1
    width: 50
    anchors.top: parent.top
    anchors.left: prev.right
    minimum: 1
    maximum: 5
    @onValueChange: |
      local prize = 40 + 10*(self:getValue()-1)
      self:getParent():getChildById('prize'):setText(prize..' Emeralds')

  Label
    id: prize
    color: white
    text: 40 Emeralds
    text-auto-resize: true
    icon-align: left
    icon: /images/game/shop/prize
    text-offset: 21 0
    font: verdana-11px-rounded
    anchors.verticalCenter: spinBox.verticalCenter
    anchors.left: spinBox.right
    margin-left: 3

  Button
    !text: tr('Cancel')
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    @onClick: modules.game_shop.destroyClanWindow()

  Button
    id: okButton
    text: Ok
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: prev.left
    margin-right: 5

shopWindow < MainWindow
  id: shopWindow
  size: 582 336
  icon-align: right
  icon: /images/ui/shop_window
  anchors.centerIn: parent
  margin-right: 64
  draggable: false
  padding: 10
  @onEscape: modules.game_shop.hide()

  ShopTabBarVertical
    id: shopTabBar
    phantom: true
    height: 326
    anchors.top: parent.top
    anchors.left: parent.left
    margin-left: -10

  Panel
    id: shopTabContent
    height: 242
    anchors.left: prev.right
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    margin-left: 10
    margin-bottom: 35

  Label
    id: emeraldsLabel
    text-offset: 40 0
    text-auto-resize: true
    icon: /images/topbuttons/emerald_shop
    icon-align: left
    font: newfont-16px-rounded
    anchors.bottom: parent.bottom
    anchors.left: shopTabBar.right
    margin-left: 10
    margin-bottom: 5

  Label
    !text: tr('Search')..':'
    text-auto-resize: true
    anchors.right: next.left
    anchors.verticalCenter: next.verticalCenter
    margin-right: 5

  TextEdit
    id: searchText
    width: 135
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-right: 10
    shift-navigation: true
    @onTextChange: searchOffer()

  UIButton
    id: closeButton
    anchors.top: parent.top
    anchors.right: parent.right
    size: 23 22
    image-source: /images/ui/shop_button_close
    image-clip: 0 0 23 22
    @onClick: modules.game_shop.hide()

    $hover:
      image-clip: 0 22 23 22

    $pressed:
      image-clip: 0 44 23 22
Whats is wrong on code?
 
Last edited by a moderator:
shop.otui, also check if the indentations are correct
Lua:
wrong?
shopWindow < MainWindow

should be:
MainWindow
It was like that in the original script, still giving the same error and others about "verticalTab"
Lua:
ERROR: failed to load UI from 'shop.otui': 'ShopTabBarVertical' is not a defined style
FATAL ERROR: Unable to load module 'game_shop': /modules/game_shop/shop.lua:152: attempt to index global 'shopWindow' (a nil value)
 
It was like that in the original script, still giving the same error and others about "verticalTab"
Lua:
ERROR: failed to load UI from 'shop.otui': 'ShopTabBarVertical' is not a defined style
FATAL ERROR: Unable to load module 'game_shop': /modules/game_shop/shop.lua:152: attempt to index global 'shopWindow' (a nil value)
Code:
ClanWindow < MainWindow
  size: 210 100
  @onEscape: modules.game_shop.destroyClanWindow()

  Label
    text: Rank:
    width: 38
    anchors.top: parent.top
    anchors.left: parent.left
    margin-top: 2

  SpinBox
    id: spinBox
    step: 1
    width: 50
    anchors.top: parent.top
    anchors.left: prev.right
    minimum: 1
    maximum: 5
    @onValueChange: |
      local prize = 40 + 10*(self:getValue()-1)
      self:getParent():getChildById('prize'):setText(prize..' Emeralds')

  Label
    id: prize
    color: white
    text: 40 Emeralds
    text-auto-resize: true
    icon-align: left
    icon: /images/game/shop/prize
    text-offset: 21 0
    font: verdana-11px-rounded
    anchors.verticalCenter: spinBox.verticalCenter
    anchors.left: spinBox.right
    margin-left: 3

  Button
    !text: tr('Cancel')
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    @onClick: modules.game_shop.destroyClanWindow()

  Button
    id: okButton
    text: Ok
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: prev.left
    margin-right: 5

  shopWindow < MainWindow
    id: shopWindow
    size: 582 336
    icon-align: right
    icon: /images/ui/shop_window
    anchors.centerIn: parent
    margin-right: 64
    draggable: false
    padding: 10
    @onEscape: modules.game_shop.hide()

  ShopTabBar
    id: shopTabBar
    phantom: true
    height: 326
    anchors.top: parent.top
    anchors.left: parent.left
    margin-left: -10

  Panel
    id: shopTabContent
    height: 242
    anchors.left: prev.right
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    margin-left: 10
    margin-bottom: 35

  Label
    id: emeraldsLabel
    text-offset: 40 0
    text-auto-resize: true
    icon: /images/topbuttons/emerald_shop
    icon-align: left
    font: newfont-16px-rounded
    anchors.bottom: parent.bottom
    anchors.left: shopTabBar.right
    margin-left: 10
    margin-bottom: 5

  Label
    !text: tr('Search')..':'
    text-auto-resize: true
    anchors.right: next.left
    anchors.verticalCenter: next.verticalCenter
    margin-right: 5

  TextEdit
    id: searchText
    width: 135
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-right: 10
    shift-navigation: true
    @onTextChange: searchOffer()

  UIButton
    id: closeButton
    anchors.top: parent.top
    anchors.right: parent.right
    size: 23 22
    image-source: /images/ui/shop_button_close
    image-clip: 0 0 23 22
    @onClick: modules.game_shop.hide()

    $hover:
      image-clip: 0 22 23 22

    $pressed:
      image-clip: 0 44 23 22
 
Code:
ClanWindow < MainWindow
  size: 210 100
  @onEscape: modules.game_shop.destroyClanWindow()

  Label
    text: Rank:
    width: 38
    anchors.top: parent.top
    anchors.left: parent.left
    margin-top: 2

  SpinBox
    id: spinBox
    step: 1
    width: 50
    anchors.top: parent.top
    anchors.left: prev.right
    minimum: 1
    maximum: 5
    @onValueChange: |
      local prize = 40 + 10*(self:getValue()-1)
      self:getParent():getChildById('prize'):setText(prize..' Emeralds')

  Label
    id: prize
    color: white
    text: 40 Emeralds
    text-auto-resize: true
    icon-align: left
    icon: /images/game/shop/prize
    text-offset: 21 0
    font: verdana-11px-rounded
    anchors.verticalCenter: spinBox.verticalCenter
    anchors.left: spinBox.right
    margin-left: 3

  Button
    !text: tr('Cancel')
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    @onClick: modules.game_shop.destroyClanWindow()

  Button
    id: okButton
    text: Ok
    width: 64
    anchors.bottom: parent.bottom
    anchors.right: prev.left
    margin-right: 5

  shopWindow < MainWindow
    id: shopWindow
    size: 582 336
    icon-align: right
    icon: /images/ui/shop_window
    anchors.centerIn: parent
    margin-right: 64
    draggable: false
    padding: 10
    @onEscape: modules.game_shop.hide()

  ShopTabBar
    id: shopTabBar
    phantom: true
    height: 326
    anchors.top: parent.top
    anchors.left: parent.left
    margin-left: -10

  Panel
    id: shopTabContent
    height: 242
    anchors.left: prev.right
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    margin-left: 10
    margin-bottom: 35

  Label
    id: emeraldsLabel
    text-offset: 40 0
    text-auto-resize: true
    icon: /images/topbuttons/emerald_shop
    icon-align: left
    font: newfont-16px-rounded
    anchors.bottom: parent.bottom
    anchors.left: shopTabBar.right
    margin-left: 10
    margin-bottom: 5

  Label
    !text: tr('Search')..':'
    text-auto-resize: true
    anchors.right: next.left
    anchors.verticalCenter: next.verticalCenter
    margin-right: 5

  TextEdit
    id: searchText
    width: 135
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-right: 10
    shift-navigation: true
    @onTextChange: searchOffer()

  UIButton
    id: closeButton
    anchors.top: parent.top
    anchors.right: parent.right
    size: 23 22
    image-source: /images/ui/shop_button_close
    image-clip: 0 0 23 22
    @onClick: modules.game_shop.hide()

    $hover:
      image-clip: 0 22 23 22

    $pressed:
      image-clip: 0 44 23 22
Same error.

Lua:
FATAL ERROR: Unable to load module 'game_shop': /modules/game_shop/shop.lua:151: attempt to index global 'shopWindow' (a nil value)
stack traceback:
    [C]: in function '__index'
    /modules/game_shop/shop.lua:151: in function 'init'
    /modules/game_shop/shop.otmod:9:[@onLoad]:1: in main chunk
    [C]: in function 'ensureModuleLoaded'
    /init.lua:64: in function 'loadModules'
    /init.lua:86: in main chunk
 
local shopWindow is present at the beggining of shop.lua?

If this is your "main" window:
Lua:
shopWindow < MainWindow(...)
Then why it is declared inside of this?:
Lua:
ClanWindow < MainWindow(...)

What you try to achieve by this?
 
Back
Top