Selected Weapon via Script

Place to get help with not working mods / modding interface.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2182
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Selected Weapon via Script

Post by Ranakastrasz »

Is it possible to detect what weapon the player has selected, when they fire it, and/or set what weapon is selected?

If so, what functions do I need to use?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Selected Weapon via Script

Post by Nexela »

Getting gun/ammo
https://github.com/Nexela/Nanobots/blob ... ol.lua#L72

When they are fired .... I don't believe so If I recall ammo_inventory_changed only triggers when the stack size changes and not the ammo size.

Set/weapon .. Have not looked into this. if you can't do it directly you can do it indirectly by setting the active gun/ammo to what you want.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2182
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Selected Weapon via Script

Post by Ranakastrasz »

Well, the other part works. Still need to detect when a weapon is fired.

Was going to use an entity-creation to cause an event in script, but there isn't an event for that.

on_trigger_created_entity
Called when an entity with a trigger prototype (such as capsules) create an entity AND that trigger prototype defined trigger_created_entity="true".

This seems like it might work, but I really don't know how it would work. I have no examples.

Going to use an On-tick event engine I think. I don't really have an alternative.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Post Reply

Return to “Modding help”