• 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 Creating items on no ground tile

Sprrw

Well-Known Member
Joined
Jun 22, 2021
Messages
100
Reaction score
55
Location
Sweden
Hello folks how would I go about adding an item in the air (so not on a ground tile).
so atm Im trying to use doCreateItem(itemId, count, pos) and that works great when creating items on ground tiles but it doesnt seem to work like I want it to.
Bonus question, is there any better looking way to create items? Something like, pos:createItem(type, count).

Info : Tfs 1.4

Img :

1679079153162.png
Create item over the tile the chimeny is located at.

Thanks for reading! Much appreciated!
 
interesting question, there is an old trick I guess cykotitan/mkalo/colandus/mock told us once upon a time...
you need to create some combat area stuffy to get it working like you want but test this:
Lua:
function Position:createItem(itemid, count)
    local toTile = Tile(self)
    if not toTile or not toTile:getItems() or not toTile:getGround() then
        doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
        Game.createItem(itemid, count, self)
    end
end

then you can use it like you want pos:createItem(itemId, count)
 
Thanks a lot m8!

but I tried using it like
Lua:
chimneyTutorialHousePos.createItem(smoke, 1)
and it doesnt seem to do anything (no error tho).
Updated nm. Tried with ":" instead of "." idk I always seem to mess that up... But now I got an error of 'createItem' a nil value
 
@Sprrw Try to use the trick that @StreamSide posted, I played a bit with it, see:

Use colons to execute:
Lua:
chimneyTutorialHousePos:createItem(smoke, 1)
 
@Sprrw Try to use the trick that @StreamSide posted, I played a bit with it, see:

Use colons to execute:
Lua:
chimneyTutorialHousePos:createItem(smoke, 1)
Hey! Thanks a lot for keeping up with my newbieness xd Well Yea I tried that aswell but now Im getting the error of createItem a nil value :(
 
Well actually that would've work too, but I prefer to define things already as object for static things to not have to instanciate them every time I want to re-use same value (only drawback is that it holds the memory alocated)
 
Back
Top