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

Question of "populating crates/chests/box's" ect

Heatblade12

Member
Joined
Aug 12, 2013
Messages
24
Reaction score
6
Long story short im useing Remeres Map editor, and i have a map (The Forgotten Server) with a massive amount of empty chests, boxs, crates, ect... any way to add random items to them without manually doing it myself? ie, a tool that populates boxs with junk, or 2-4 gold ect?
 
LUA function on startup, give coordinates for entire map.
let it go trough all the tiles and find containers.
If containers are empty add stuff in it randomly for static list of items you allow to spawn.
You can even generate items by chance or limit the items, so lets say place 1 war hammer to any of the crates, but its only there once.
 
sounds like i need to code it via LUA? that's beyond my ability. i can edit, follow someone else's work, but do it from scratch, i would not know where to begin.
 
lucky for you, LUA scripts are easy to implement.
Just go to your data folder. there find folder globaevents, then there should scripts folder and open startup.lua file

on that file you add the code inside the function and logic like i mentioned before is quite simple.
Just create 2 positions parameters one for 1 corner, another opposite corner. (aka map corners)
Then with this you can create table of entire map.
then loop trough each position and check for tile, if exists loop trough all the possible containers you want to have something in it.
check if there is something, if not. you can create randomly some items from list of itemID table you created for this.
and that is it.
 
lucky for you, LUA scripts are easy to implement.
Just go to your data folder. there find folder globaevents, then there should scripts folder and open startup.lua file

on that file you add the code inside the function and logic like i mentioned before is quite simple.
Just create 2 positions parameters one for 1 corner, another opposite corner. (aka map corners)
Then with this you can create table of entire map.
then loop trough each position and check for tile, if exists loop trough all the possible containers you want to have something in it.
check if there is something, if not. you can create randomly some items from list of itemID table you created for this.
and that is it.
It would take ages to get all the positions if you have a big area.

The best thing to do in this case would be creating an action and add the items as the player opens it (I'm pretty sure this is not possible with Lua so you would need to edit the sources to do that.)
 
It would take ages to get all the positions if you have a big area.
yeah, what of it if starting up server takes 5 minutes? big deal.. players get to play 5 minutes later.

The best thing to do in this case would be creating an action and add the items as the player opens it (I'm pretty sure this is not possible with Lua so you would need to edit the sources to do that.)
yes that is also possible with LUA. Actually quite nice too, because if item happns to have uniqueID or AID it wont execute the random loot thing.

idea is that when you use item, you get the item userdata. so make it so if its empty container you can generate items in it and keep track of that item so it will have some kind of cooldown when it changes. I actually have something similar on my server. And with the upcoming quest I have some items now what turns even noncontainer items into containers if I want them to automatically
 
huh, i was hoping something like this was out there just ready to be used, like it was done before, but its sounded like this is just something that is out of my skill.
the map im using right now is The forgotten server v1.2, im just running it for singleplayer, i populated it with npcs to trade with ect, added a few spawns, changed a few areas. added a quest giver, but the massive amount of random crates around the world is way too much to manually put items into.

A LUA that can generate items as the player opens an object would be perfect haha. as long as it didnt repopulate the box everytime the player opened it... XD
 
When the player opens the chest, change the action ID to 0 (with the random generator thing)? I don't know if its possible though
 
When the player opens the chest, change the action ID to 0 (with the random generator thing)? I don't know if its possible though
not rly, maybe there was some way, I just removed the item and recreated it if i want to remove AID xD (its automatic for me anyway when i use setActionId(nil)) but on default TFS it doesn't do anything imo.
but why would you change actionId?
you can simply have a global table storing the container uniqueID with timestamp when it was last used.
 
I think you are right. I thought he wanted to generate some minor loot and then just leave the chest empty. BTW, can you move items with unique ID's?
 
you can simply have a global table storing the container uniqueID with timestamp when it was last used.
corrections: can't use uniqueID in TFS 1.2, they always have new uid when used. forgot that..

If you don't allow moving the containers then SUM of pos.x and pos.y can be used as the table key.
Or even better, to use item text to store the os.time()
 
Wouldn't it be possible to index all the containers in the given area once and save their locations?
so that the first time you run the command it will take a while but after that you should be able to cut down on that time as you've already located all the containers.

Also you'd have to write an exception for the containers in houses.
 
You could simplify this with an action script, use the item's item id rather than an action which would need to be applied to every container, by using the item id of the container you could be more specific by generating a loot chance to that container type.

So if you had thousands of 1738
latest
you could apply an onUse chance to click on that type, a chance for it to yield loot or be empty, transforming the box to trash would eliminate the need to generate massive storage tables.
 
The above are right. Actions are the best way to do this.

Just set up an action for the items you want to have randomized loot.

When you randomize the loot, do something to the item to "mark" it as complete. (Whitevo's idea with os.time() is good because then you can have the loot randomize again after a cooldown)
 
Back
Top