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

New slot type.

spyk3z

Theós:Undying
Joined
Jul 23, 2007
Messages
385
Reaction score
90
Location
Home.
So I've added my slot type on my server.
Added it to player.lua in the gamelib folder.
Code:
InventorySlotOther = 0
InventorySlotHead = 1
InventorySlotNeck = 2
InventorySlotBack = 3
InventorySlotBody = 4
InventorySlotRight = 5
InventorySlotLeft = 6
InventorySlotLeg = 7
InventorySlotFeet = 8
InventorySlotFinger = 9
InventorySlotFinger2 = 13
InventorySlotAmmo = 10
InventorySlotPurse = 11

InventorySlotFirst = 1
InventorySlotLast = 10

Added it to const.h
Code:
    enum InventorySlot {
        InventorySlotHead = 1,
        InventorySlotNecklace,
        InventorySlotBackpack,
        InventorySlotArmor,
        InventorySlotRight,
        InventorySlotLeft,
        InventorySlotLegs,
        InventorySlotFeet,
        InventorySlotRing,
        InventorySlotRing2,
        InventorySlotAmmo,
        InventorySlotPurse,
        InventorySlotExt1,
        InventorySlotExt2,
        InventorySlotExt3,
        InventorySlotExt4,
        LastInventorySlot
    };

Then in my game_inventory files.
Code:
InventorySlotStyles = {
  [InventorySlotHead] = "HeadSlot",
  [InventorySlotNeck] = "NeckSlot",
  [InventorySlotBack] = "BackSlot",
  [InventorySlotBody] = "BodySlot",
  [InventorySlotRight] = "RightSlot",
  [InventorySlotLeft] = "LeftSlot",
  [InventorySlotLeg] = "LegSlot",
  [InventorySlotFeet] = "FeetSlot",
  [InventorySlotFinger] = "FingerSlot",
  [InventorySlotFinger2] = "FingerSlot2",
  [InventorySlotAmmo] = "AmmoSlot"
}
Code:
  FingerSlot2 < InventoryItem
  id: slot13
  image-source: /images/game/slots/finger
  &position: {x=65536, y=9, z=0}

But I get this error when I run the client.

Code:
ERROR: Unable to send extended opcode 1, extended opcodes are not enabled
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:94: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
    [C]: in function '__index'
    /game_inventory/inventory.lua:94: in function 'onInventoryChange'
    /game_inventory/inventory.lua:60: in function </game_inventory/inventory.lua:56>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:94: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
    [C]: in function '__index'
    /game_inventory/inventory.lua:94: in function </game_inventory/inventory.lua:84>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:94: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
    [C]: in function '__index'
    /game_inventory/inventory.lua:94: in function </game_inventory/inventory.lua:84>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:94: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
    [C]: in function '__index'
    /game_inventory/inventory.lua:94: in function </game_inventory/inventory.lua:84>
 
I'm just going to show you a comaprison of the yours and the official source to show you what you did wrong
Yours
Code:
InventorySlotOther = 0
InventorySlotHead = 1 // 1st
InventorySlotNeck = 2
InventorySlotBack = 3
InventorySlotBody = 4
InventorySlotRight = 5
InventorySlotLeft = 6
InventorySlotLeg = 7
InventorySlotFeet = 8
InventorySlotFinger = 9
InventorySlotFinger2 = 13
InventorySlotAmmo = 10 // last
InventorySlotPurse = 11

InventorySlotFirst = 1
InventorySlotLast = 10

Official source
Code:
InventorySlotOther = 0
InventorySlotHead = 1 // 1st
InventorySlotNeck = 2
InventorySlotBack = 3
InventorySlotBody = 4
InventorySlotRight = 5
InventorySlotLeft = 6
InventorySlotLeg = 7
InventorySlotFeet = 8
InventorySlotFinger = 9
InventorySlotAmmo = 10
InventorySlotDistance = 11
InventorySlotPurse = 12 // last

InventorySlotFirst = InventorySlotHead
InventorySlotLast = InventorySlotPurse
 
Last edited:
Did you got it ?

It's not really hard work, I made it today in a couple of hours.
You need to have a great knowledge about your source, I work with mine for a long time, so I was able to do the modifications, and in the client is just a few modifications, I did not used gamelib at all, this is just to "help" you using variable names.
 
Did you got it ?

It's not really hard work, I made it today in a couple of hours.
You need to have a great knowledge about your source, I work with mine for a long time, so I was able to do the modifications, and in the client is just a few modifications, I did not used gamelib at all, this is just to "help" you using variable names.
could you post how you did it? i can figure out how to get it to work

regards men
 
It has been a long time since I made it, however as I said before, it's not a really hard work, you need only to be aware from variables limitations (uint8_t / uint16_t) [recommend you to try to add just one, and than the others], and you will just need to replicate code, mainly at player.cpp (it will be in other files too, so use a good project finder)

Wish I was able to help ;)
 
Back
Top