Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for Container class section #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions source/includes/classes/_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ local function changeQualityAt(user, theDepot)

if success then
local oldQuality = theItem.quality
local qualityChanged = theDepot:changeQualityAt(1, 333)
local wantedQuality = 999
local changeNeeded = wantedQuality - oldQuality
local qualityChanged = theDepot:changeQualityAt(1, changeNeeded)
success, theItem = theDepot:viewItemNr(1)
if qualityChanged and success then
local newQuality = theItem.quality
Expand All @@ -82,9 +84,9 @@ local function changeQualityAt(user, theDepot)
end
```

This function is supposed to change the quality of the item at the given position inside the container to whatever the amount integer is set to. It returns as true if it worked.
This function changes the quality of the item at the given position inside the container by whatever the amount integer is set to. It returns as true if it worked.
The quality value of an item is a three digit integer, where the first digit corresponds to quality (0-9) and the latter digits correspond to durability (00-99).
[For some reason, this function does not work currently.](https://github.com/Illarion-eV/Illarion-Server/issues/81)
If the amount integer + the quality the item already is equals to higher than the maximum quality of 999 then the quality will not be changed while the durability will be set to the maximum of 99.

#### `boolean insertContainer(Item item, Container container, number itempos)`

Expand Down Expand Up @@ -171,12 +173,29 @@ Erases an amount of the specified itemid that is the same as the count integer f
```lua
local function increaseAtPos(user, theDepot)

theDepot:increaseAtPos(1, 40)
local itemPosition = 37

local success, theItem = theDepot:viewItemNr(itemPosition)

local oldAmount
local itemId

if success then
oldAmount = theItem.number
itemName = theItem.id
else
return --no item was found
end

local amountToAdd = 40
local newTotalAmount = theDepot:increaseAtPos(itemPosition, amountToAdd)

user:inform("You've added "..newTotalAmount-oldAmount.." out of the set "..amountToAdd.." requested additions to the item in slot "..itemPosition.." with the id of "..itemId.." making for a total of "..newTotalAmount.." from the previous "..oldAmount)
end
```
Increase the number of items at the given itempos by value.
It should return the number of items increase, [but currently it does not.](https://github.com/Illarion-eV/Illarion-Server/issues/82)
Increase the number of items at the given itempos by value, returning the new amount if upon success.
If the total number exceeds the stack limit of the items, only enough to reach the stack limit will be added.
This function also works with negative numbers to subtract item amounts instead.

#### `boolean swapAtPos(number itempos, number newId, number newQuality)`

Expand Down