burst and burstrate weapondef table issue

burst and burstrate weapondef table issue

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

burst and burstrate weapondef table issue

Post by smoth »

Code: Select all

		Spring.Echo(WeaponDefs[weapoDefId].burst, 
					WeaponDefs[weapoDefId].burstRate, 
					WeaponDefs[weapoDefId].burstrate,
					WeaponDefs[weapoDefId].description,
					WeaponDefs[weapoDefId].turret)
outputs:

Code: Select all

 nil, nil, nil, 3 barreled shotgun, true
here is the def:

Code: Select all

-- Cannon Base Class
local CannonClass = Weapon:New{
	areaOfEffect		= 8,
	avoidFriendly		= true,
	beamTime			= 0.01,
	beamWeapon			= true,
	burnblow			= true,
	collideFriendly		= false,
	color				= 33,
	coreThickness		= 0.1,
	explosionGenerator	= "custom:shotgunImpact",
	id					= 237,
	impactOnly			= 0, 
	impulseFactor		= -1,
	largeBeamLaser		= true,
	lineOfSight			= true,
	name				= "shotgun",
	noSelfDamage		= true,
	randomdecay			= "0.3",
	range				= 700,
	reloadtime			= 0.9,
	renderType			= 0,
	smokedelay			= "1",
	soundStart			= "shotgun",
	soundTrigger		= true,
	sprayAngle			= 2024,
	startsmoke			= "1",
	texture1			= "shot",
	texture2			= "empty",
	texture3			= "empty",
	texture4			= "empty",
	thickness			= 1,
	tolerance			= 200,
	turret				= true,
	weaponTimer			= 1,
	weaponVelocity		= 700,
	weaponVelocity		= 1000,
	projectiles			= 5,
	customparams = {
		effect1			= "largeanddirtymuzzle",
		animation		= "headers/weapons/cannon.lua"

	},		
	
	damage = {
		default			= 100,
	},
}

local trippleshotgun = CannonClass:New{
	name				= "3 barreled shotgun",	
	reloadtime			= 1.5,
	burst				= 3,
	burstrate 			= 0.01,
	projectiles			= 1,
	customparams = {
		linked		= true,
	},
}	


-- Return only the full weapons
return lowerkeys({
	trippleshotgun = trippleshotgun,
})
why is burst and burstrate nil?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: burst and burstrate weapondef table issue

Post by FLOZi »

Code: Select all

WEAPONTAG(int, salvosize).externalName("burst").defaultValue(1);

Code: Select all

WEAPONTAG(float, salvodelay).externalName("burstRate").defaultValue(0.1f);
Try WeaponDefs[weaponDefId].salvoSize and WeaponDefs[weaponDefId].salvoDelay

Wiki updated to reflect how to access via lua
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: burst and burstrate weapondef table issue

Post by smoth »

ah

I was trying salvosize last night! thanks flozi!

do you know of any way to walk a unitdef/weapondef table?

Code: Select all

for k,v in pairs(WeaponDefs[weapoDefId]) do		
	Spring.Echo(k,v)
end
results in:

Code: Select all

pairs, <function>
next, <function>
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: burst and burstrate weapondef table issue

Post by FLOZi »

http://springrts.com/wiki/Lua_UnitDefs# ... l_unitdefs

Short answer is "use def:pairs() instead of of pairs(def)"
Post Reply

Return to “Game Development”