Jump to content

Recommended Posts

Hi everyone,

I have pretty good ideas for Don't Starve mods but I have a big problem. My programming knowledge is close to 0 ... I have tried to learn a little bit but all I've learned until now is to edit some TUNINGs and make a simple config file for my mods.

Now I have some ideas for new mods, but I would like to know how to:

- Run a script (function I guess), at game load, that looks for all existing containers (fridge, chest, character inventory, bags), and then looks for any item inside them that matches X condition. If any item matches my condition, then drop Y number of that item from the container to the ground (the number of each item would depend of that item)

- Make a message appear in-game, that last X seconds and then disappear.

- Introduce certain item inside a container, but not be able to remove the item from that container until the item breaks.

- Use the characteristic code that stone/wood walls have (You can place them one close to each other, and the next wall you try to place, automatically goes right next to an already placed wall if the mouse is close enough to the existing wall, I can make a video and post it if I didn't explain it well enough) and add that behavior to a new/existing item (I would also like to be able to edit distances between these items, or not, I will have to test it if I manage to progress with the mod).

There are all the doubts I have for now.

Now that you have an idea of what I want to do, Could you help me to get enough programming knowledge to be able to do these things? I mean, I've taken a look at the possible wall placement code (I guess it is) and I have no idea at all of what's inside the file xD

Spoiler

return {
  version = "1.1",
  luaversion = "5.1",
  orientation = "orthogonal",
  width = 16,
  height = 16,
  tilewidth = 16,
  tileheight = 16,
  properties = {},
  tilesets = {
    {
      name = "tiles",
      firstgid = 1,
      tilewidth = 64,
      tileheight = 64,
      spacing = 0,
      margin = 0,
      image = "../../../../tools/tiled/dont_starve/tiles.png",
      imagewidth = 512,
      imageheight = 384,
      properties = {},
      tiles = {}
    }
  },
  layers = {
    {
      type = "tilelayer",
      name = "BG_TILES",
      x = 0,
      y = 0,
      width = 16,
      height = 16,
      visible = true,
      opacity = 1,
      properties = {},
      encoding = "lua",
      data = {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        29, 0, 0, 0, 29, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        29, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      }
    },
    {
      type = "objectgroup",
      name = "FG_OBJECTS",
      visible = true,
      opacity = 1,
      properties = {},
      objects = {
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 0,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = "1"
          }
        },
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 0,
          y = 16,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = "1"
          }
        },
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 0,
          y = 96,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = ".3"
          }
        },
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 96,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = ".3"
          }
        },
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 112,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = ".3"
          }
        },
        {
          name = "",
          type = "wall_ruins",
          shape = "rectangle",
          x = 128,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            ["data.health.percent"] = ".3"
          }
        },
        {
          name = "",
          type = "brokenwall_ruins",
          shape = "rectangle",
          x = 0,
          y = 112,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            [""] = ""
          }
        },
        {
          name = "",
          type = "brokenwall_ruins",
          shape = "rectangle",
          x = 144,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            [""] = ""
          }
        },
        {
          name = "",
          type = "brokenwall_ruins",
          shape = "rectangle",
          x = 160,
          y = 0,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            [""] = ""
          }
        },
        {
          name = "",
          type = "brokenwall_ruins",
          shape = "rectangle",
          x = 0,
          y = 160,
          width = 0,
          height = 0,
          visible = true,
          properties = {
            [""] = ""
          }
        }
      }
    }
  }
}

How do I learn so much that I could make all these ideas become real mods? I don't plan to put my ideas here and force someone to write the code for me, I don't like that because I feel like I will be happier and will learn more of this if I do it by myself (with a lot of help xD)

With help I mean; "The code to make a message appear and dissapear after X seconds may be in X Don't Starve file, take a look, do some tries with your mod and come back if you still can't manage to set it correctly or you get crashes", things like that. I would like you to show me the path while I travel for that path and get my own experiences.

I will probably have more questions related to new ideas, or problems that will appear while i try to make mods. Do I have to create new threads or can I use this thread for them?

 

All the help you can provide will be welcomed

___________________________________________________________________________________________________________________________

I'll be posting here the things I'd like to do:

 

  • I'm working on a mod that adds two new items to the game, but I have a little issue:

I have this on my modmain.lua file

Spoiler

local TECH = GLOBAL.TECH

local newitem = GLOBAL.Recipe("newitem", { Ingredient("existingitem", 2), Ingredient("existingitem", 4)}, RECIPETABS.MAGIC, TECH.MAGIC_TWO)

But the game says I need a Prestihatitator to prototype. Am I missing something? The mod seems to work correctly except for that little fact that I don't know how to fix.

 

  • I'm trying to make a tool that has a higher chance to cause Ents to wake up and rise. I've read the evergreens.lua file but I have a few issues;

There are two local functions, the first one works when a tree is being chopped (I guess?), and the second one works when the tree is completely chopped down.

Spoiler

--tell any nearby leifs to wake up
    local pt = Vector3(inst.Transform:GetWorldPosition())
    local ents = TheSim:FindEntities(pt.x,pt.y,pt.z, TUNING.LEIF_REAWAKEN_RADIUS, {"leif"})
    for k,v in pairs(ents) do
        if v.components.sleeper and v.components.sleeper:IsAsleep() then
            v:DoTaskInTime(math.random(), function() v.components.sleeper:WakeUp() end)
        end
        v.components.combat:SuggestTarget(chopper)
    end

Does this mean that while the player is chopping a tree, there's a chance for Ents to "wake up"? And, does "wake up" means the tree (Ent) is idle until a chopped down tree activates it?

Not 100% sure but I think this is the code that rises Ents

Spoiler

if target  then
                    target.noleif = true
                    target.leifscale = growth_stages[target.components.growable.stage].leifscale or 1
                    target:DoTaskInTime(1 + math.random()*3, function() 
                        if target and not target:HasTag("stump") and not target:HasTag("burnt") and
                            target.components.growable and target.components.growable.stage <= 3 then
                            local target = target
                            if builds[target.build] and builds[target.build].leif then
                                local leif = SpawnPrefab(builds[target.build].leif)
                                if leif then
                                    local scale = target.leifscale
                                    local r,g,b,a = target.AnimState:GetMultColour()
                                    leif.AnimState:SetMultColour(r,g,b,a)
                                    
                                    --we should serialize this?
                                    leif.components.locomotor.walkspeed = leif.components.locomotor.walkspeed*scale
                                    leif.components.combat.defaultdamage = leif.components.combat.defaultdamage*scale
                                    leif.components.health.maxhealth = leif.components.health.maxhealth*scale
                                    leif.components.health.currenthealth = leif.components.health.currenthealth*scale
                                    leif.components.combat.hitrange = leif.components.combat.hitrange*scale
                                    leif.components.combat.attackrange = leif.components.combat.attackrange*scale
                                    
                                    leif.Transform:SetScale(scale,scale,scale) 
                                    leif.components.combat:SuggestTarget(chopper)
                                    leif.sg:GoToState("spawn")
                                    target:Remove()
                                    
                                    leif.Transform:SetPosition(target.Transform:GetWorldPosition())
                                end
                            end
                        end
                    end)
                end

If the highlighted text is the one that affects the probability of a tree to turn into an Ent, and the probability of a chop down tree to rise an Ent, those parts would be the text I would need to modify, but only if the character is using my tool. The thing is, I don't know how to do it. The idea is to give Ents a higher chance to respawn, but only if the tree is being chopped/chopped down with a specific item, my tool.

Edited by Sergio A V
I would like to remove my own doublepost

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
×
  • Create New...