Jump to content

Protect things


Zeyn

Recommended Posts

Hi there !

 

I would like to create my first mod. The aim is to make the Wooden thing objects more difficult to take.

 

- The Ring thing will be surround by Tall birds

- The Crank thing will be surround by Tentacles

- The Box thing will be surround by Gardian Pigs

- The Metal Potato thing will be surround by Obelisks. Obelisks are down if all players around it have less than 30 sanity. If a player have more than 30 sanity and come next to it, Obelisks will lift up.

- I also want to spawn more Clockwork Knigt, Clockwork Bishop and Clockwork Castle next to the platform.

 

I have created a folder in dont_starve/mods and have made a modinfo.lua and a modmain.lua files. But i don't know where to begin with my modmain.lua file. How can i get the Ring Thing position for example ?

 

 

Link to comment
Share on other sites

As someone who has just had a little success with spawning custom set pieces, I think this is definitely doable. Can't really help much with the coding side, but you'll have to edit the set piece static_layout files (data>scripts>map>static_layouts). This tutorial can help you learn the basics of Tiled, the program you can use to edit the static_layouts: 

Link to comment
Share on other sites

Thanks Justjasper, there are some interresting files in data>scripts>map>static_layouts like

- teleportato_potato_layout.lua

- teleportato_crank_layout.lua

- teleportato_box_layout.lua

- teleportato_base_layout.lua

 

I will read your link : Making a custom piece, it seems very interresting

Link to comment
Share on other sites

I wanted to replace the pig king in sandbox with the pig king (surrounded with pig torches) from adventure mode. So I realised I wanted to do pretty much the same thing as you, so I thought I'd let you know where I'm at.

 

I based my mod off a texture replacing mod, which basically mimics the folder structure in 'data' and overrides the builds with the textures they want to change. I thought it might be a similar process for overwriting a set piece file.

 

So I created a scripts > map > static_layouts folder in my mod folder and put the overriding set piece in. Apparently this doesn't work for overriding the set piece like a texture, as my mod screen crashes when it tries to sync. There's probably some modmain or worldgenmain code that we'd need to get it working, but I'm still trying to figure out what it is.

 

If nobody is more forthcoming on the thread and I find out a solution, I will let you know. Good luck!

Link to comment
Share on other sites

Can we have the coordonates of the Pig King location, like  player.Transform:GetWorldPosition() to get the player location ? If we can have the location of the Pig King, it would be easy to create some pig tower around.

Link to comment
Share on other sites

Ents is a globally visible list so its used just by its name in nearly any file.  The modmain has a slightly restricted namespace. Globally available lists/variables/functions are required to have their name prefixed with  'GLOBAL.'   so try using   GLOBAL.Ents

Link to comment
Share on other sites

For JustJasper : You can do something like this

function DefendedKing(player)	for k, v in pairs(GLOBAL.Ents) do    if v.prefab == "pigking" then     	        local x, y ,z = v.Transform:GetWorldPosition()		local torch1 = GLOBAL.SpawnPrefab("forest/objects/pigtorch")  		local torch2 = GLOBAL.SpawnPrefab("forest/objects/pigtorch") 		local torch3 = GLOBAL.SpawnPrefab("forest/objects/pigtorch") 		local torch4 = GLOBAL.SpawnPrefab("forest/objects/pigtorch") 		local t = 6		torch1.Transform:SetPosition( x+t, y, z)		torch2.Transform:SetPosition( x, y, z+t)		torch3.Transform:SetPosition( x-t, y, z)		torch4.Transform:SetPosition( x, y, z-t)        break -- break_if    end -- end_if	end -- end_forend --end_functionAddSimPostInit(DefendedKing)
Link to comment
Share on other sites

player in line 1 isn't necessary

The simpostinit sends the player isntance as the first argument to whatever function you choose as your callback.  In your case you choose  "DefendedKing" as your callback function.   If you had made your function 

 

function DefendedKing( sillyRabbit )

 

 

then inside the function sillyRabbit would be the player.  You can give it any name you want.  You can also just ignore it by not including a variable name at all which doesnt break anything, BUT its always best to have your callback functions match the signature of what is calling them.  It avoids confusion

Link to comment
Share on other sites

My mod is nearly finished, but there is one last problem.

 

If my mod create some creatures after the world is generating, like i wanted, it also create the same creatures when i load a saved game, so each time i save my game and i launch it, the mod create others creatures.

 

How can i do if i want to activate my mod just after the world generation and nevermore ? (sorry if my english is not correct)

 

 

Link to comment
Share on other sites

based on gamelogic.lua, line 912:

 

if GetClock().numcycles == 0 and GetClock():GetNormTime() == 0 then

 

EDIT: I should mention this fires the Maxwell intro. "Cycle" is the day and "normtime" is the time of the current day. In english: Day 0, 0 o'clock

Link to comment
Share on other sites

Hy here !

 

I have learnt how to create a simple set piece with the link of JustJasper (the tutorial created by JackSlender, thx to him).

 

I would like to make a better version of my ProtectedThings Mod (a 2.0 version), but i have some problems :

- When we create a setpiece, how can we do to create just one in the world and not a lot like in the tutorial

- I would like to replace the default crank set piece of the world by mine, because i still want to have just one crank thing in the world and i would like to create it like i want it to be

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...