The Minor JSON Questions Thread

Another question: How do you make an item with multiple “use_action” promt the user with a menu to select the action? Currently, I have the following:

"use_action": [
      {
        "target": "abm_belt_cloth_shot_unfinished",
        "msg": "You adjust the belt to house shotshells.",
        "menu_text": "Adjust for shotshells",
        "type": "transform"
      },
      {
        "target": "abm_belt_cloth_50_unfinished",
        "msg": "You adjust the belt to house .50 bullets.",
        "menu_text": "Adjust for .50",
        "type": "transform"
      }
    ],

It defaults to the first option when activated. Is it possible to have the user choose?

[quote=“Maddremor, post:101, topic:12858”]Another question: How do you make an item with multiple “use_action” promt the user with a menu to select the action? Currently, I have the following:

"use_action": [
      {
        "target": "abm_belt_cloth_shot_unfinished",
        "msg": "You adjust the belt to house shotshells.",
        "menu_text": "Adjust for shotshells",
        "type": "transform"
      },
      {
        "target": "abm_belt_cloth_50_unfinished",
        "msg": "You adjust the belt to house .50 bullets.",
        "menu_text": "Adjust for .50",
        "type": "transform"
      }
    ],

It defaults to the first option when activated. Is it possible to have the user choose?[/quote]

I believe you need to create several copies of your item with transform actions with different target, like this:

  {
    "id": "candle_smoke",
    "copy-from": "candle",
    "type": "GENERIC",
    "name": "smoking candle",
    "description": "A candle in every respect, but designed to produce a thin stream of smoke.  Often used in ceremonies or to add an air of 'ambient mystery', but could likely be used to reduce scent by windows and doors it is placed next to.",
    "emits": [ "emit_smoke_flare" ],
    "use_action": {
      "target":  "candle_smoke_lit",
      "msg": "You light the smoking candle.",
      "active": true,
      "need_fire": 1,
      "menu_text": "Light",
      "type": "transform"
    }
  },
  {
    "id": "candle_smoke_lit",
    "type": "TOOL",
    "name": "smoking candle (lit)",
    "name_plural": "smoking candles (lit)",
    "copy-from": "candle_lit",
    "description": "This smoking candle is lit, providing both aeromatic smoke and light.",
    "emits": [ "emit_smoke_flare" ],
    "use_action": {
      "target": "candle_smoke",
      "msg": "The candle winks out.",
      "menu_text": "Extinguish",
      "type": "transform"
    },
    "flags": [ "LIGHT_8", "TRADER_AVOID" ]
  }

So it will go like this:

candle_smoke_lit -> candle_smoke -> candle_smoke_lit

If Im understanding the question, you want to be able to take an item and make several ‘branches’ of items from it. Transform should only honor the last transform option input.

  • You can try to create a 6 second recipe that is accessed from the crafting menu.
  • You could also make them all rotate. i.e. ammo_shot_belt goes to ammo_50_belt goes to ammo_unused_belt goes to ammo_shot_belt. By this method the player only needs to be aware this function exists.
  • You could make the player define its ammo as they create the item i.e. they dont craft the generic version.

i am making a mod that adds more energy weapons but when the world loads it says “result: c-23 in recipe c-23 is not valid” or something like that

You probably have a recipe that has the wrong item ID as result.

thanks alec white yes you were right. the item id was s-23 not c-23 :stuck_out_tongue:

Anyone know why my custom lighter can start overworld fires but wont spark a cigar?

{
“id”: “ref_lighter_string”,
“type”: “TOOL_ARMOR”,
“name”: “wearable lighter”,
“copy-from”: “lighter”,
“description”: “A lighter with a bit of string and taping to allow it to be worn about the neck like a lanyard. A bit fumbly to get a hold of, but perfectly servicable.”,
“weight”: 25,
“volume”: 0,
“price”: 3000,
“material”: “aluminum”,
“symbol”: “,”,
“color”: “light_gray”,
“coverage”: 1,
“encumbrance”: 0,
“storage”: 0,
“warmth”: 0,
“material_thickness”: 1,
“ammo”: “gasoline”,
“max_charges”: 50,
“rand_charges”: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 7, 11, 13, 17, 21, 27 ],
“charges_per_use”: 1,
“use_action”: [
{
“type”: “firestarter”,
“moves”: 60,
“moves_slow”: 600
}
]
},

[quote=“pisskop, post:107, topic:12858”]Anyone know why my custom lighter can start overworld fires but wont spark a cigar?

{
“id”: “ref_lighter_string”,
“type”: “TOOL_ARMOR”,
“name”: “wearable lighter”,
“copy-from”: “lighter”,
“description”: “A lighter with a bit of string and taping to allow it to be worn about the neck like a lanyard. A bit fumbly to get a hold of, but perfectly servicable.”,
“weight”: 25,
“volume”: 0,
“price”: 3000,
“material”: “aluminum”,
“symbol”: “,”,
“color”: “light_gray”,
“coverage”: 1,
“encumbrance”: 0,
“storage”: 0,
“warmth”: 0,
“material_thickness”: 1,
“ammo”: “gasoline”,
“max_charges”: 50,
“rand_charges”: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 7, 11, 13, 17, 21, 27 ],
“charges_per_use”: 1,
“use_action”: [
{
“type”: “firestarter”,
“moves”: 60,
“moves_slow”: 600
}
]
},[/quote]

int iuse::smoking(player *p, item *it, bool, const tripoint&)
{
    bool hasFire = (p->has_charges("fire", 1));

    // make sure we're not already smoking something
    if( !check_litcig( *p ) ) {
        return 0;
    }

    if (!hasFire) {
        p->add_msg_if_player(m_info, _("You don't have anything to light it with!"));
        return 0;
}

ref_lighter_on = refillable lighter (lit) also does not provide fire for cigarettes.

You can check this in LUA console by this command:

game.add_msg(tostring(player:has_charges(“fire”,1)))


Probably same issue as described in https://github.com/CleverRaven/Cataclysm-DDA/issues/21005

oh hey, thanks for the update edit.

I was doing my own doodadaling with the jsons and came to the conclusion that it must be a hardcode somewhere?

how do I reduce the number of mandatory overmap specials in More Locations and Z-Level Buildings mod?

Inside the overmap special.json file there are tags for [occurances].

You mod those two bracketed numbers.

Numbers range from [-1,-1] to … … whatever.

-1 means 'no limit’
0 means 'none’
A number represents its contemporary quantity.

The first number is a minimal amount. the second a max.

… and for the record, Id shy away from using -1. it scares the game.

So is there anything in the Jason’s for the latest experimental s that determines how much engine power a combustion engine has or is this something that is hard coded now?

Is it possible to get a turret to run off battery charge any longer?

It needs to be declared in its item definition Json now.

It should be. If not, it’s probably a bug. Provide an example though - I’m not sure what kind of battery powering do you have in mind. Battery as magazine, vehicle battery, battery-using-gun specified to use UPS not working or what?

Well, I have a gun that uses battery to fire. A tesla coil, if you will.

The gun was originally intended to be too unwieldy to use by hand, but could be mounted. Back when car batteries could be charged via standard batteries it worked fine when mounted, drawing 100 charge per shot, doing minimal damage per shot, but stunning, lighting up, and bouncing off enemies.

The gun, Ive been informed, will still require batteries when mounted, due to the new turret mechanics.

Anywho, the issue may be the ups version of the gun not drawing power at all from ups.
Which is another issue entirely, but this shockcannon is incompatible with a ups conversion kit. I got around that by making an actual ups powered version, but it will not draw power from ups, making it an infinite ammo gun.

Weapons may have problems consuming electricity directly, if ammo is specified to be battery, as there is no instance of this happening in core game.
If you want to use it that way, report it, but it may later bitrot again for as long as there is no turret in the core that works this way.

The UPS part however is an obvious bug. UPS weapons are supposed to properly draw power from vehicle storage.

it actually works now, with some tweaking. thanks!

needed some adjusting, but i do think if battery is an ammo than conversation kits should work on any type of item that could accept them

How do I add in a custom monster? Not looking to have it naturally spawn yet, just want a custom monster I can spawn through debug menu for now.

Look at monsters.json and copy the entry that most matches your monster in question. Then modify it and slap the file with that bit of code in a mod.

easiest way is to copy one from

/data/json/monsters

and give it a new id. if you felt like it you could give all the monsters exactly identical stats. except the id. id has to differ.

try to take a mon that is somrwhat similar to your own idea.

p:. you evil ninja