Page 1 of 1
I need thies scripts
Posted: 02 Oct 2014, 22:57
by TheDarkOne
So...can someone give me codes for this?
-unit that moves and fires
-spawn the unit at start
-end game when that unit dies
Re: I need thies scripts
Posted: 02 Oct 2014, 23:00
by gajop
Regarding 2 and 3 question, read
http://springrts.com/wiki/Lua_Scripting , in particular
http://springrts.com/wiki/Lua_SyncedCtrl
http://springrts.com/wiki/Lua_SyncedRead
http://springrts.com/wiki/Lua:Callins
and if you still can't manage to do it, tells us what you've tried.
People are willing to help here, but you need to show greater effort on your side.
Re: I need thies scripts
Posted: 02 Oct 2014, 23:21
by PicassoCT
unit that moves and fires, if its unitdef contains a weapon, and the modell contains a piece called center
Code: Select all
center=piece"center"
function script.Create()
--generatepiecesTableAndArrayCode(unitID)
end
function script.Killed(recentDamage,_)
return 1
end
----aimining & fire weapon
function script.AimFromWeapon1()
return center
end
function script.QueryWeapon1()
return center
end
function script.AimWeapon1( Heading ,pitch)
--aiming animation: instantly turn the gun towards the enemy
return true
end
function script.FireWeapon1()
return true
end
function script.StartMoving()
end
function script.StopMoving()
end
function script.Activate()
return 1
end
function script.Deactivate()
return 0
end
function script.QueryBuildInfo()
return center
end
function script.QueryNanoPiece()
return center
end
gadget that spawns unit in table for every team
date = "Oh, you wish, you had it with this file - but she got class,style and format.",
Code: Select all
function gadget:GetInfo()
return {
name = "Test Gadget spamming a test unit -if team is not Gaia",
desc = "Creates Units ",
author = "PicassoCT",
date = "Oh, you wish, you had it with this file - but she got class, style and format.",
license = "GNU GPL, v2 its goes in all fields",
layer = 0,
enabled = true -- loaded by default?
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- synced only
if (gadgetHandler:IsSyncedCode()) then
UnitList={"UnitNameGoesHere"}
function gadget:GameFrame(f)
if f == 900 then
teamList=Spring.GetTeamList()
local gaiaTeamId=Spring.GetGaiaTeamID()
for i=1, #teamList do
if teamList[i] ~= gaiaTeamId then
x,z= Spring.GetTeamStartPosition(teamList[i])
if x then
for j=1,#UnitList,1 do
Spring.CreateUnit(UnitList[j],x+(j-#UnitList/2)*50,0,z+(j-#UnitList/2)*50,0,teamList[i])
end
end
end
end
end
end
end
Fragment for a gadget when unit destroyed
Code: Select all
function gadget:UnitDestroyed(unitID, unitDefID, unitTeamID)
if unitTeamID == gaiaTeamID and ignoreGaia ~= 0 then
-- skip gaia
return
end
local teamUnitCount = teamsUnitCount[unitTeamID]
if teamUnitCount then
teamUnitCount = teamUnitCount - 1
teamsUnitCount[unitTeamID] = teamUnitCount
end
local allyTeamID = teamToAllyTeam[unitTeamID]
local allyUnitCount = allyTeamUnitCount[allyTeamID]
if allyUnitCount then
allyUnitCount = allyUnitCount - 1
allyTeamUnitCount[allyTeamID] = allyUnitCount
end
end
I may not have posted correct code, but i provoke jK and knorke into action, and thus your problem is salviad
Re: I need thies scripts
Posted: 02 Oct 2014, 23:40
by gajop
Picasso, please redo your post, the code you've posted is unnecessarily too complicated and a bit unreadable. Keep in mind that you are dealing with a complete beginner here.
Re: I need thies scripts
Posted: 09 Oct 2014, 10:08
by knorke
unit that moves/fires:
http://springrts.com/wiki/Animation-LuaScripting
especially the "Stumpy Tutorial" linked there
spawn unit at game start:
https://github.com/spring/spring/blob/d ... _spawn.lua
(this folder and files come with spring install too)
end game when
that unit dies:
Many games like BA, XTA, zK have "kill the commander" gamemodes but those scripts are quite longwinded...Don't know any easy example.
Re: I need thies scripts
Posted: 09 Oct 2014, 13:23
by PicassoCT
You are to late Knorke, he is mine, i corrupted him first :)
Re: I need thies scripts
Posted: 09 Oct 2014, 14:29
by Jools
knorke wrote:
end game when that unit dies:
Many games like BA, XTA, zK have "kill the commander" gamemodes but those scripts are quite longwinded...Don't know any easy example.
BA one is not that long, maybe that could serve as an example.
XTA one is long because it's been patched so many times, because people always have to invent some new creative way in which to die.
Re: I need thies scripts
Posted: 09 Oct 2014, 14:46
by Silentwings
BA one... maybe that could serve as an example.
It's not a great example because although it is short it is not standalone, but may be the best there is.