I need thies scripts

I need thies scripts

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
TheDarkOne
Posts: 39
Joined: 01 Dec 2013, 23:15

I need thies scripts

Post 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
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: I need thies scripts

Post 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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: I need thies scripts

Post 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
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: I need thies scripts

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: I need thies scripts

Post 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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: I need thies scripts

Post by PicassoCT »

You are to late Knorke, he is mine, i corrupted him first :)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: I need thies scripts

Post 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.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: I need thies scripts

Post 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.
Post Reply

Return to “Lua Scripts”