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?
Selected Weapon via Script
- Ranakastrasz
- Smart Inserter

- Posts: 2182
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Selected Weapon via Script
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Selected Weapon via Script
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.
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.
- Ranakastrasz
- Smart Inserter

- Posts: 2182
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Selected Weapon via Script
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.
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
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16