Page 1 of 1

Selected Weapon via Script

Posted: Sat Mar 25, 2017 11:31 pm
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?

Re: Selected Weapon via Script

Posted: Sun Mar 26, 2017 12:27 am
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.

Re: Selected Weapon via Script

Posted: Sun Mar 26, 2017 6:37 pm
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.