Zeyn Posted February 11, 2015 Share Posted February 11, 2015 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 More sharing options...
justjasper Posted February 11, 2015 Share Posted February 11, 2015 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: Making a Custom Set Piece by JackSlender Link to comment Share on other sites More sharing options...
Zeyn Posted February 11, 2015 Author Share Posted February 11, 2015 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 More sharing options...
justjasper Posted February 16, 2015 Share Posted February 16, 2015 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 More sharing options...
Zeyn Posted February 18, 2015 Author Share Posted February 18, 2015 Cool ! The mod you want to make is very close to what i want to do. Hope you will find your solution. I think you will find it before me cause i am a beginner in modding ! Link to comment Share on other sites More sharing options...
Zeyn Posted February 20, 2015 Author Share Posted February 20, 2015 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 More sharing options...
Mobbstar Posted February 20, 2015 Share Posted February 20, 2015 for k, v in pairs(Ents) do if v.prefab == "pigking" then [....] break endend Link to comment Share on other sites More sharing options...
Zeyn Posted February 20, 2015 Author Share Posted February 20, 2015 Thanks a lot Mobbstar ! I will try it ! Link to comment Share on other sites More sharing options...
Zeyn Posted February 21, 2015 Author Share Posted February 21, 2015 I have an error message when i try to use in pairs(Ents) : bad argument #1 to pairs (table expected, got nil) Link to comment Share on other sites More sharing options...
seronis Posted February 21, 2015 Share Posted February 21, 2015 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 More sharing options...
Zeyn Posted February 21, 2015 Author Share Posted February 21, 2015 GG Seronis, it works ! Thaks a lot Link to comment Share on other sites More sharing options...
Zeyn Posted February 21, 2015 Author Share Posted February 21, 2015 For JustJasper : You can do something like thisfunction 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 More sharing options...
Zeyn Posted February 21, 2015 Author Share Posted February 21, 2015 player in line 1 isn't necessary Link to comment Share on other sites More sharing options...
seronis Posted February 21, 2015 Share Posted February 21, 2015 player in line 1 isn't necessaryThe 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 More sharing options...
Zeyn Posted February 22, 2015 Author Share Posted February 22, 2015 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 More sharing options...
Mobbstar Posted February 22, 2015 Share Posted February 22, 2015 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 More sharing options...
Zeyn Posted February 22, 2015 Author Share Posted February 22, 2015 GG Mobbstar ! It works ! Thanks (i just have to change GetClock() with GLOBAL.GetClock() ) Link to comment Share on other sites More sharing options...
Zeyn Posted March 2, 2015 Author Share Posted March 2, 2015 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 More sharing options...
Zeyn Posted March 3, 2015 Author Share Posted March 3, 2015 I have found a solution by myself and it seems to work ! Link to comment Share on other sites More sharing options...
Recommended Posts
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.