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

Lua Moveitem function

Gevond

New Member
Joined
Jan 23, 2018
Messages
9
Reaction score
0
Hello.

Does anyone know any way to check whether the item was thrown from a player's inventory or from the ground?
I was hoping there was a LUA function for that, but I couldn't find it.

What I want to do is a move event that when a player throws an item, the script will check if
the item was thrown from their inventory or from the ground.

That would help me a lot.

Thanks in advance.
 
So u want to do a event where peoples are supposed to move a special item as explain "2160" yes?

im sure its possible to do a script which does not allow peoples to drop other items ?
 
Last edited:
I'm using The OTX Server Version: (2.100 - 6000)
Client 7.6

Well, the main problem is that it is possible to put items on dirt walls (any other wall works totally fine), but since I've already tried to
edit the items.otb file and check the "blocking" attribute and that didn't work, the next thing I want to try is to write a script
that does the aforementioned move event.

Picture of the problem:
JaRQPXH.png


This is what I've written so far:

Lua:
function onAddItem(moveitem, tileitem, position, cid)

   if -- * thrown from container * -- then                       -- using "fromPos" is not possible since it's not in the onAddItem parameters
       -- thrown from container or inventory
       if moveitem.type > 1 then  
           -- item is stackable
           doRemoveItem(moveitem.uid, moveitem.type)   -- removes items that were put on the wall
           doPlayerAddItem(cid,moveitem.itemid,moveitem.type)   -- returns items to the player
       else                      
           -- item is not stackable
           doRemoveItem(moveitem.uid, 1)               -- removes item that was put on the wall
           doPlayerAddItem(cid,moveitem.itemid,moveitem.type)   -- returns the item to the player
       end
   else
       -- thrown from ground      
       if moveitem.type > 1 then  
           -- item is stackable
           doRemoveItem(moveitem.uid, moveitem.type)   -- removes items that were put on the wall
           doCreateItem(--*fromPos?*--, moveitem.type)   -- returns the item to the position it was thrown from
       else                      
           -- item is not stackable
           doRemoveItem(moveitem.uid, 1)               -- removes item that was put on the wall
           doCreateItem(--*fromPos?*--, moveitem.type)   -- how could I get the position where it was thrown from without using fromPos... is that possible?
       end
      
      
   end
   return true
  
end
 
Can you post the items.xml entry for these dirt walls and a screenshot of the properties from the item editor, which you used to edit items.otb.
 
Of course.

XML:
<item id="356-367" article="a" name="dirt wall">

I used otitemeditor version 0.3.9, here's the screenshot of how it looked before:

EYDUAW1.png



But after looking another wall attributes, I edited it and now it looks like this:

nxn112B.png
 
If that dirt wall is in the "ground" item group, the issue might be that the server does not check the ground item for its attributes when an item is added to a tile.
To fix that you would have to edit Tile::queryAdd (or something similar) in tile.cpp.
 
Thanks for you support, Summ, but... I ain't got that much experience to try editing that cpp file, I'll do my best to do something about that tho.

Besides, I was thinking, could there be a way to edit the dirt wall entry in the items.xml file so that the blocking attribute gets active?

I tried adding this attribute but it didn't work.
XML:
<item id="356-367" article="a" name="dirt wall">
       <attribute key="blocksolid" value="1"/>
   </item>
 
Back
Top