Modding Discussion Tenant and sellers restock with different item.will they?

Discussion in 'Starbound Modding' started by amirmiked12, Mar 23, 2017.

  1. amirmiked12

    amirmiked12 Parsec Taste Tester

    Is there any mod or any way to make sellers and tenants sell different things after some or 2 days cause when u see they are selling same things after 1 week that's boring.. Just like frog furnishing or lara augumenr shop..
    Any information will be appreciated.
     
  2. The | Suit

    The | Suit Agent S. Forum Moderator

    Look at the Furniture Seller in the outpost, ( top left )
    He changes his stock every 24 hours.
     
  3. amirmiked12

    amirmiked12 Parsec Taste Tester

    no i mean how to make those random generate sellers in planets to sell different things when after some hours or days.
     
  4. IHart

    IHart Scruffy Nerf-Herder

    The Suit means: yes you can do that, look at the code for the merchants that already do something similar for clues.
     
  5. amirmiked12

    amirmiked12 Parsec Taste Tester

    oh ok..tnx
     
  6. amirmiked12

    amirmiked12 Parsec Taste Tester

    ive gotta say i didnt find anything useful ..can you all help me more??
     
  7. IHart

    IHart Scruffy Nerf-Herder

    your quest, should you choose to accept it, is to figure out how frog furnishings changes his stock
     
  8. Cyel

    Cyel Scruffy Nerf-Herder

    In the scripts/actions/merchant.lua:
    Code:
      -- Reset the PRNG so the same seed always generates the same set of items.
      -- The uint64_t seed can get truncated when converted to a lua double, but
      -- it will at least provide a deterministic seed, even if the full range of
      -- input seeds can't be used
      local seed
      if config.getParameter("merchant.rotateStock", false) then
      seed = math.floor(os.time() / config.getParameter("merchant.rotationTime"))
      else
      seed = tonumber(npc.seed())
      end
    [...] 
     
    amirmiked12 likes this.
  9. amirmiked12

    amirmiked12 Parsec Taste Tester

    i should make a patch and change merchant.rotatstock to yes?
    i dont think lua files will able to be patched.
     
    IHart likes this.
  10. Cyel

    Cyel Scruffy Nerf-Herder

    Yes, I guess patching /npcs/merchant.npctype and add rotateStock = true there would make it work on newly-spawned merchants.

    You cann't patch lua files, only overwrite them, and it's generally the recipe for incompatibilities between mods
     
  11. Nemasys

    Nemasys Cosmic Narwhal

    Don't overwrite the Lua file. Just make a new one. Copy the one you want to alter, rename it, and then change what you need to change. Be sure to reference the new Lua file in your tenant file though.
     
  12. Cyel

    Cyel Scruffy Nerf-Herder

    >Be sure to reference the new Lua file in your tenant file
    (to do that you'd have to patch the /behaviors/npc/merchant.behavior file
     
  13. amirmiked12

    amirmiked12 Parsec Taste Tester

    im not that goooood at coding.
    as yall told me
    i should copy the merchant.lua file and rename it to anything i want and then find that line and change it??
    and make folders just like its original place and place .lua file in there?
    thats it?
    uploaded it as .txt cause forum wont allow extension
     

    Attached Files:

  14. Cyel

    Cyel Scruffy Nerf-Herder

    That's more or less how you'd do it yes, you'd need to, as I said, patch the behavior file to add your script, but your script as-is won't do anything I fear.

    Did you tried simply patching /npcs/merchant.npctype and add rotateStock?

    Code:
    [ {"op":"add","path":"/scriptConfig/merchant/rotateStock","value":true} ]
     
  15. amirmiked12

    amirmiked12 Parsec Taste Tester

    Right now im not on my laptop I'm on my phone .tnx I will do it and let u know what happened.
    And one more question how many hours or days its gonna take to rotate?
     
  16. Cyel

    Cyel Scruffy Nerf-Herder

    Ah, good question, it's calculated with "merchant.rotationTime", so here's the actual patch you'd need:
    [
    {"op":"add","path":"/scriptConfig/merchant/rotateStock","value":true},
    {"op":"add","path":"/scriptConfig/merchant/rotationTime","value":86400}
    ]

    86400 is the time in seconds, it's what the vanilla merchants use, one day
     
  17. amirmiked12

    amirmiked12 Parsec Taste Tester

    Oh tnx it's a day in seconds
     
  18. amirmiked12

    amirmiked12 Parsec Taste Tester

    and what should i name my patch exactly?/
    and is this folder branching right?
    mod\merchant stock rotate\behaviors\npc
    ?
     
  19. Cyel

    Cyel Scruffy Nerf-Herder

    This is one single patch, should be in /npcs/merchant.npctype.patch
     
  20. amirmiked12

    amirmiked12 Parsec Taste Tester

    tnx im going to test
     

Share This Page