Jump to content

[GUIDE] How to create Set Pieces...


Recommended Posts

Okay I am trying to use this to put 1 layout on the level. and i want it to go in any task. is there an easy way to populate tasks = {} will all possible tasks including those from mods?

 

also can you do this sort of thing with prefabs. like a unique world object that is spawned at random on the level.

Edited by afetogbo
Link to comment
Share on other sites

@afetogbo, the answer to your first question is yes there is an easy way of doing that.

require("map/tasks")local tasks = tasks.sampletasks

This is how tasks work.

 

map/tasks.lua

local tasklist = {}function AddTask(name, data)	table.insert(tasklist, Task(name, data))endtasks = {	sampletasks = tasklist,	oneofeverything = everything_sample,	GetTaskByName = GetTaskByName,} 

 

To expand on what I mean, is you will need to iterate through the tasks obtaining the name of each and inserting them in to a new table.

 

require("map/tasks")local tasklist = tasks.sampletaskslocal task_names = {} for _, task in pairs(tasklist) do   table.insert(task_names, task.id)end  

 

The answer to your second question is irrelevant to the topic at hand. Spawning unique world objects at random can be done in a similar method. I will be creating a new tutorial for that with wrapper sample code to make it easy to do. However, I will say it is possible and like creating Set Pieces traditionally it requires a massive amount of code to do it correctly. Keep your eye on the forums over the next couple of days for a fully working tutorial on spawning world objects.

 

 

Edit:

Expanded on what I meant about how to properly obtain task names.

Edited by Kzisor
Link to comment
Share on other sites

I put the second code block in my modwoldgenmain.lua and i get this error modworldgenmain.lua"]:135: attempt to index global 'tasks' (a nil value)

 

line 135 is local tasklist = tasks.sampletasks

 

before this i was trying to access tasklist from tasks.lua but I couldn't figure a way of doing it. That makes me feel good that I was on the right track although still a noob at all this.

Link to comment
Share on other sites

I put the second code block in my modwoldgenmain.lua and i get this error modworldgenmain.lua"]:135: attempt to index global 'tasks' (a nil value)

 

line 135 is local tasklist = tasks.sampletasks

 

before this i was trying to access tasklist from tasks.lua but I couldn't figure a way of doing it. That makes me feel good that I was on the right track although still a noob at all this.

 

I've modified the actual code to change local tasks = tasks.sampletasks into local task_names = tasks.sampletasks.

 

You may have to put GLOBAL.tasks.sampletasks to make it work right if you're not using my mod environment from the downloads page.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...