tormentedmage Posted November 13, 2021 Share Posted November 13, 2021 (edited) I currently try to remove all the items from the map and tried three short codes. local function lootTest() local player = getPlayer(); player:getInventory():removeAllItems(); end Events.OnNewGame.Add(lootTest); local function lootTest2(zombie) zombie:getInventory():removeAllItems(); end Events.OnZombieDead.Add(lootTest2); local function lootTest3() local container = getContainer(); container:getInventory():removeAllItems(); end Events.OnNewGame.Add(lootTest3); The first one and the second one work well but the third one doesn't work at all. Probably I don't correctly specify containers and I don't know how to specify all the containers at once. I would appreciate if someone could fix the code. Edited November 22, 2021 by tormentedmage Solved Link to comment Share on other sites More sharing options...
Tchernobill Posted November 14, 2021 Share Posted November 14, 2021 1/ If I set aside the strangeness of your attempt: you could parse all squares and for each of them: parse static objects for containers parse dynamic objects for containers parse vehicles for containers for each of theses containers: remove all items inside them 2/ why would you remove all items from a world ? you'd probably better create a world without items. Link to comment Share on other sites More sharing options...
tormentedmage Posted November 15, 2021 Author Share Posted November 15, 2021 Thank you for the answer. I make codes from my curiosity and it's fun for me even when they are totally useless. By the way,I still can't write a decent code and don't understand how to specify containers. Could you show me an example code which actually works? Link to comment Share on other sites More sharing options...
Tchernobill Posted November 15, 2021 Share Posted November 15, 2021 I did something similar for container access in AutoLoot mod. see in AutoLoot.lua file the function AutoLoot_PlunderSquare(playerObj, square) Link to comment Share on other sites More sharing options...
tormentedmage Posted November 16, 2021 Author Share Posted November 16, 2021 I subscribed your mod and found many things I can learn. I hope I can fix my wrong code by myself. I really appreciate your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now