Jump to content

needs weapontypes.lua an update?


eloragon

Recommended Posts

Hi Modders and Developers,

I tried to use the global variable WeaponTypes to determine the type of a Turret Weapon. The only clue is weapon.prefix. But unfortunately the 'id' in the WeaponTypes and the prefix on a weapon do not match.
Here is a sample code:

the basics:

local ctTurret, ctWeapon
function GetInventorySelect()
	ctTurret = customInventory.inventory.input.selected.item --works perfect
end

function GetWeaponType()
	local weapons = {ctTurret:getWeapons()}
	if not ctWeapon then
		for _, weapon in pairs(weapons) do
			ctWeapon = weapon
		end
	end

	for prefix, id in pairs(WeaponTypes) do
		if prefix == ctWeapon.prefix then
			return id
		end
	end
	return nil
end

in WeaponTypes we have (weapontypes.lua):

WeaponTypes["ChainGun"] = 0

But at the Turret Weapon we have (weapongenerator.lua):

weapon.prefix = "Chaingun /* Weapon Prefix*/"%_t

So when I try to get the correct weapon type of the selected inventory turret I get the translated prefix which I can't match with the WeaponTypes.

Are the ID's in weapontypes.lua something else or is there another way to determine the type of a weapon in the inventory?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...