Modding Help Custom Tenant Requirements?

Discussion in 'Starbound Modding' started by ImHereForTheMods, Jun 26, 2020.

  1. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Hi all, I'm looking in to doing some edits to the way tenants work, but I'm running into some roadblocks at the moment, so am wondering if somebody may have some answers.

    I have the assets unpacked and all, and upon looking at a tenant file the structure is quite straight-forward and easy to understand...

    Code:
    {
      "name": "chef_apex",
      "priority": 4,
    
      "colonyTagCriteria": {
        "light": 1,
        "door": 1,
        "apex": 8,
        "cooking": 8
      },
    
      "tenants": [
        {
          "spawn": "npc",
          "species": "apex",
          "type": "chefmerchanttenant",
          "overrides": {
           }
         }
       ],
    
      "rent": {
        "periodRange": [900.0, 1800.0],
        "pool": "merchantGift"
      }
    }
    

    colonyTagCriteria is what makes them spawn.
    tenants section sets who to spawn
    rent sets their rent

    Now what I'd be interested in doing is having some custom colony tag criteria... Though the problem with this is I'm not sure how to go about that. I have a general idea how the code should work, but I guess doing it is different.

    My idea would be to have a certain object be required, or to have a container with a certain object type in it.
    The idea ultimately would be to implement NPC hunger to add work to colonies.


    My thought process is...
    Basically --> if object is present and holds (object type(food)) and other criteria (door, light)are filled, then spawn tenant.
    also... deplete (object type(food)) a certain amount over a certain amount of seconds.
    and I guess I'd also need if (object type(food)) = 0 then ... (grumble?(not sure what grumble is/does) and refuse rent.

    oh... and probably if world is unloaded(i think that's the term) then decrease rate of (food) depletion.

    Would be useful to know how my thinking process is, and the like.

    Apparently the relevant code seems to be in the colonydeed's lua... not tenant lua, so figured that much out.
    Though if ya'll know of any good references on starbound lua, or anything I should know/try feel free to let me know.

    tbh I don't really know any lua at all, but I figured starbound may be a decent place to fool around with it and maybe learn something/create something cool.

    I can somewhat understand what most code does, but I'm having a hard time finding relevant code for what I want to do.
    Thanks all in advance. Appreciate it.
     
  2. projectmayhem

    projectmayhem Spaceman Spiff

    Grumble, if I recall right, is what happens what the tenants living area does not meet the requirements because of changes. For example, if you break the door, which is required for them to spawn, they will grumble for a while, then eventually despawn. I do not know enough about lua to help you out. I would assume you would need the colony deed to check X amounts of blocks around it for the container, and then check the container contents. I cant think of any mod off the top of my head that has a similar function.

    As far as the tags go, those are defined in an objects file. You will see a tag that looks like this "colonyTags" : ["pretty" , "science", "tier1"]. All the things inside this array count towards the criteria for spawning a tenant.

    If you want to see more of how grumble works, look at grumble.dialog in the dialog folder.
     
  3. bk3k

    bk3k Oxygen Tank

    I don't think colony tags are the way you'd want to go about hunger. Seeing this I might mention I have a colony overhaul in the works.
    It isn't all the way finished but in a fairly workable state. But what I've done so far is focusing on the colony deed side of things. I haven't messed with the NPC side quite yet. But while I let colony tags still control what tenant spawns, I built a different system to assets other needs. For some things, I'm looking at the name of the object and searching for strings in that name. For other things I am looking at the category of the object and "storage" is one such thing. Most things I'm looking only within the tenant's space, but for teleporters I'm looking in a radius.
    I want people to have incentive to create nicer apartments. I also wanted to make things more convenient in exchange, so they can all pay into a rent box without need of manual collection. Yes this could be viewed as a idle production system of sorts. I have a sort of level system for the apartment where I made a separate JSON file.
    Code:
    [
      [  //lv1
        { "type": "bed", "count": 1, "per_tenant": true }
        //{ "type": "hygiene", "count": 0.75, "per_tenant": true }
      ],
      [  //lv2
        { "type": "chair", "count": 1, "per_tenant": true },
        { "type": "tab", "count": 1, "per_tenant": false }
      ],
      [  //lv3
        { "type": "container", "count": 1, "per_tenant": true },
        { "type": "fridgestorage", "count": 0.5, "per_tenant": false }
      ],
      [  //lv4
        { "type": "furniture", "count": 2, "per_tenant": true },
        { "type": "decoration", "count": 1.5, "per_tenant": true }
      ],
      [  //lv5
        { "type": "wire", "count": 1, "per_tenant": false },
        { "type": "hygiene", "count": 1, "per_tenant": true },
        { "type": "teleporter", "count": 1, "per_tenant": false }
      ]
    ]
    I check level 1 requirements, and then level 2 requirements, etc. You can get more rent with with a nicer apartment (space also matters).
    But you see I'm already checking for a fridge, which is probably what you want to do. But currently I have that set per-apartment rather than checking for a fridge in proximity. I'm not sure which way you'd want to do it.


    I thought about having hunger as well, but I'm not entirely sure. But how it could work is add another timer to the deed (there are already some running such as rent). When the timer is up, it scans for containers - perhaps only refrigerated storage - and checks the contents of those containers. If there is food, then it can send a message to the tenant (which is what collecting rent does anyhow). That would require some extra code for the NPCs, but I still need to review their existing code anyhow. I mean you'd want them to then move to the container, and consume 1 food item. If there is no food, I'd just hijack the existing grumble system as @projectmayhem suggests. Maybe the timer for next time could depend on the "foodValue" of the item that gets consumed. Should the NPCs get status effects too? That's possible, though I don't know how necessary it is.

    You could perhaps have a whole system to see what food they would select (when there is a choice), or just randomly select food (the easy option). Now that brings us to the question... what does the player get for feeding them? I mean food has value, and requires either work to produce or pixels to buy it. So there needs to be a payoff for the player of some sort IMO. Maybe you've put more thought into that aspect than I have. If you're doing your own mod then I certainly wouldn't add hunger to mine. Maybe that's better to have it separate so players can choose what aspects they want. But I'd definitely want to make sure our mods work together well.

    I've also considered this... changing up tenants a little. That some tenants won't pay you rent, but work for you instead. That means guards won't pay rent either, but they kill monsters. Perhaps I want to make them more effective guards then. I also want to add farmers... yes NPCs that pick food ready to harvest and place it somewhere. The chef you brought up... what if they chef took the raw food and made better food with it? What about a hunter? Like a guard but uses hunting gear and collects drops (probably also drops from turrets killing things). The hunter probably needs to roam a bit further than other NPCs, or maybe you'd just place their home further out from the colony. But those ideas would integrate well with a separate tenant hunger mod. The hunter collects meat, the farmer collects crops, and the chef makes prepared food. So the work needed to meet the hunger need is lessened. But adding more NPC behaviors is more of a stretch goal of mine. It remains just an idea, and might be its own separate (but complimentary) mod.

    Anyhow I'll attach what I have in case you're curious, or if you think there is anything in there that would be useful for what you're doing then feel free.
     

    Attached Files:

  4. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Thanks for the ideas! I meant to reply earlier, but been busy with stuff...
    Your mod looks really well thought out... maybe I don't need to make one after all.. haha.

    Just got tired of how pointless and stale tenants seemed. May still mess with it a bit and see what happens. Don't really have a solid plan atm. Good to have pointers though.
    Thanks for pointing out what grumbles do too.
     
  5. The | Suit

    The | Suit Agent S. Forum Moderator

    Adding to what Bk3k said

    If you really want to use the tag system.
    A really simple mod that just uses "Food Objects" as a "requirement" then adding a tag to the food objects. Then having those food objects run on a script that "replaces" itself after a set period of time.

    What does this do? Essentially it keeps an object tagged with food - the food runs on a timer - once the timer is over tag is removed ( by switching to a different object such as an empty container )
    This is reasonably easier to accomplish but it has its own downsides, such has having to individually fill each houses food.


    The other option is run code in the Deed itself - that has a Food Variable then having a seperate object that fills "Food Variable" in large area of the colony that is nearby the object. I used to have a mod that used this technique to fill up "plants water requirement" a while back. Unfortunately I don't think I still have that code available anymore.
     

Share This Page