Page 2 of 2

Re: Noob here, with questions

Posted: 26 Nov 2009, 22:35
by Pxtl
Smoth, disproportionate rage is disproportionate.

Re: Noob here, with questions

Posted: 26 Nov 2009, 22:49
by smoth
Not really. I want to know where he gets off saying that. It really was uncalled for.

I mean look, I understand disabilities, it is painful for me to write handwritten stuff. Anything more than a page will put me to tears. I spent the last 2 years of my highschool working with the "severe and profound" Prior to that I worked with the kids who had downs syndrome. This wasn't done out of some altruism or some sort of need to feel better than them. I was an extremely violent(go figure right?) child and they wanted me to learn patience and some assholes at the school made me do community work. So when other kids in highschool took electives I had to work with the disabled. So I understand truly debilitating disorders and the pain that comes with them not just by my own disorder but from working with those miserable kids.

I can understand having some amount of added difficulty or even some methods of learning/teaching not working for different individuals but to say I cannot because of X and I am proficient... no. I hate when people say they cannot and make up and excuse. You cannot do quantum physics sure, maybe you suck at calc because you are dyslexic... but no I don't buy being unable to write lua or model. It isn't that hard and the stuff in question is not something like digging into shaders etc.

I have spent the past 4 years reading poster after poster who's biggest disability is their lack of ability to commit real and meaningful effort to anything beyond jacking off and watching tv. I think something should be said about it!

Re: Noob here, with questions

Posted: 26 Nov 2009, 22:55
by TassadarZeratul
...

I'm not at all saying I can't do Lua. I'm saying I haven't learned yet, and that methods of learning that work for most people don't work for me, at least not well. I'm trying to learn. So how about we STFU?

Also, don't try to out-emo me. I'm not going to elaborate, but I go through shit that makes your issues look like a hangnail.

EDIT: And how was it uncalled for for me to say I have a learning disability?

Re: Noob here, with questions

Posted: 26 Nov 2009, 22:58
by Pxtl
@smoth

I didn't say you were wrong, I said it was disproportionate.

My usual answer to the disability olympics? We've all got problems, we've all got obstacles - you either surmount them or you don't, and nobody's going to do it for you (unless you're a hot chick).

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:01
by lurker
Smoth, he wasn't using it as an excuse. The fact that he's not just reading the code is a separate issue.

TassadarZeratul, just go read at random for an hour and ask questions after, seriously.

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:01
by smoth
Tons of people say that TassadarZeratul, I don't buy it. You are only limited by yourself, and I believe that is where it all ultimately falls. You not your disorder define you. That stuff is all periferal and frankly I think you are/should be above it. I see things that way and it is possible I am wrong but the fact that you are supposedly proficient in a programming language tells me your disorder is irrelevant. I say irrelevant not because it doesn't mean you do not have difficulties, god no but because you are able to work around it. I think you do not give yourself enough credit and should destroy that roadblock because we are all better than that. Forgive me for having more faith in people.

Also the last two posts were directed at sinbad, not you.

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:08
by SeanHeron
TassadarZeratul, give me five minutes and you'll have some code on adding orders.

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:08
by SinbadEV
I can see why we have a beef going here smoth, but I was just trying to get you to lay off with the cranking at the n00b who indicated he has a learning disability... anyways, I completely disagree with your assessment of yourself... overcoming hardships has been long accepted as something that causes a person to improve themselves... my easy ass life is why I'm not as good as you. I have come to accept this... have fun with your incredibly awesome life, you obviously deserve it.

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:17
by smoth
Sinbad, I never overcame my disability. I still lose control of my hands and cannot always rely on them for fine motor actions. :\

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:24
by lurker
What in the world is your definition of overcome, smoth?

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:27
by SeanHeron
This is some code KDR put together to add a button to toggle a unit between a number of states (think "siege mode", etc). The "InsertUnitCmdDesc" is where the command is added to the gui (additionally to that, to stick to the Nydus example, you'd probably want some GL code showing the building at your mouse position, and then you'd need some code to actually create the unit when the command is given).

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

-- Automatically generated local definitions

local CMDTYPE_ICON_MODE   = CMDTYPE.ICON_MODE
local spCallCOBScript     = Spring.CallCOBScript
local spEditUnitCmdDesc   = Spring.EditUnitCmdDesc
local spFindUnitCmdDesc   = Spring.FindUnitCmdDesc
local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function gadget:GetInfo()
	return {
		name = "toggles",
		desc = "easy toggles",
		author = "KDR_11k (David Becker)",
		date = "2008-02-10",
		license = "Public Domain",
		layer = 1,
		enabled = true
	}
end

local CMD_TOGGLE=35950
local maxToggles=3
local toggleValue=1028

if (gadgetHandler:IsSyncedCode()) then

--SYNCED

local toggleUnit={}

local InsertUnitCmdDesc=spInsertUnitCmdDesc
local EditUnitCmdDesc=spEditUnitCmdDesc
local FindUnitCmdDesc=spFindUnitCmdDesc
local CallCOBScript=spCallCOBScript

function gadget:UnitCreated(u, ud, team)
	if toggleUnit[ud] then
		for t,d in pairs(toggleUnit[ud]) do
			InsertUnitCmdDesc(u, {
				id = CMD_TOGGLE + t,
				type=CMDTYPE_ICON_MODE,
				name=d.on,
				tooltip=d.tooltip,
				action="toggle"..t,
				params={"0",d.off,d.on}
			})
		end
	end
end

function gadget:AllowCommand(u, ud, team, cmd, param, opt)
	if cmd > CMD_TOGGLE and cmd <= CMD_TOGGLE + maxToggles then
		if toggleUnit[ud] and toggleUnit[ud][cmd - CMD_TOGGLE] then
			local toggle=toggleUnit[ud][cmd - CMD_TOGGLE]
			local f = FindUnitCmdDesc(u,cmd)
			EditUnitCmdDesc(u,f,{ params={param[1],toggle.off, toggle.on}})
			CallCOBScript(u, "Toggle", 0, cmd - CMD_TOGGLE, param[1])
		end
		return false
	end
	return true
end

function gadget:Initialize()
	for ud,d in pairs(UnitDefs) do
		local toggles={}
		for i=1,maxToggles do
			if d.customParams["toggle"..i] then
				toggles[i]={
					on=d.customParams["toggle"..i.."on"],
					off=d.customParams["toggle"..i.."off"],
					tooltip=d.customParams["toggle"..i.."tooltip"],
				}
			else
				break --toggles must be consecutive
			end
		end
		if #toggles > 0 then
			toggleUnit[ud]=toggles
		end
	end
end

else

--UNSYNCED

return false

end
As an extra, here's a little bit cut out from a different, larger gadget (again from KDR) - note that not all the definitions of variables and such are included:

Code: Select all

local rallyCmd={
	name="Rallypoint",
	tooltip="Define the location where new squads will move after being built",
	action="move",
	id=CMD_RALLY,
	type=CMDTYPE.ICON_MAP,
	cursor="Move",
}

function gadget:UnitCreated(u, ud, team)
	if bases[ud] then
		refTimers[u]=startCharge
		local x,y,z=Spring.GetUnitBasePosition(u)
		rallyPoints[u]={x,y,z+200}
		Spring.InsertUnitCmdDesc(u,rallyCmd)
	end
end

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:29
by Pxtl
Honestly, I'd just have the parent Nydus be an immobile builder with unlimited build-range, and disable building after it completes the child.

No need for extra button code or weird building-placing logic for the command. Of course there'd be lots of tricks with making sure crazy stuff doesn't happen if the building is abandoned unfinished. But you'd get Spring's building-logic and GUI for free.

Re: Noob here, with questions

Posted: 26 Nov 2009, 23:42
by SeanHeron
Well, many paths lead to rome, and I understood he was looking into how to add extra commands anyhow. (Edit: but yes, I'd agree with you Pxtl, that's prob the easier way to do it)

To get you started in general, I would grab some of the game's mentioned, and I think you should find that a lot of the gadgets are named so that their general meaning is clear :D.
Look around to see if you can find any well commented one's - that should be a good start I think ('fraid I couldn't tell you any ofhand - xept what I've messed around with but that's way too hackish to be a good start, I think :P...)

Re: Noob here, with questions

Posted: 27 Nov 2009, 00:25
by CarRepairer
TassadarZeratul wrote:Thanks for all the help, but I'm not finding it that helpful. I have a learning disability that makes it nearly impossible for me to learn from tutorials like the one linked to here. However, I can easily extrapolate from examples, meaning if someone gives me a few examples of how to do things, I can usually figure out the rest.
What is your learning disability? I think I might have it too.

Re: Noob here, with questions

Posted: 27 Nov 2009, 00:43
by Google_Frog
Has anyone said where these code examples are apart from 'unzip a mod'?
http://trac.caspring.org/browser/trunk/ ... es/Gadgets
http://trac.caspring.org/browser/trunk/ ... UI/Widgets
Here is an easy place to download CA's widgets and gadgets. The names are reasonably descriptive although could be a bit confusing if you've never played a Spring game.

The part of code that adds a command to a unit is (for example ramp)

Code: Select all

local CMD_RAMP = 39734

local rampCmdDesc = {
  id      = CMD_RAMP,
  type    = CMDTYPE.ICON_MAP,
  name    = 'Ramp',
  cursor  = 'Repair', 
  action  = 'rampground',
  tooltip = 'Build a Ramp between 2 positions',
}

function gadget:UnitCreated(unitID, unitDefID)
  local ud = UnitDefs[unitDefID]
  -- add terraform commands to builders
  if ud.isBuilder and not ud.isFactory then
    Spring.InsertUnitCmdDesc(unitID, rampCmdDesc)
  end
end
Type controls how many parameters the command will return http://springrts.com/wiki/Lua_CMDs for all the types. For playing something on the map you will want CMDTYPE.ICON_MAP. ID is just a number that you will use to detect the command. eg:

Code: Select all

local CMD_RAMP = 39734
function gadget:AllowCommand(unitID, unitDefID, teamID,cmdID, cmdParams, cmdOptions)

  if (cmdID == CMD_RAMP ) then
    -- do ramp things
  end
end
For creep building placement behaviour you may have to draw a decal and check if buildings are being placed near creep colonys.

Code: Select all

function gadget:AllowCommand(unitID, unitDefID, teamID,cmdID, cmdParams, cmdOptions)

  if (cmdID < 0 ) then -- building commands are negative
    for creepColonyTable do
      local disSQ = (Colony.x-cmdParams[1])^2 + (Colony.z-cmdParams[3])^2 -- the flat plane in spring runs perpendicular to y
      if disSQ < creepRangeSQ then
        return true -- allows the command
      end
    end
    return false -- disallows the command
  end
end
Note the above is pseudo code. There's ways to emulate the behaviour more perfectly but personally I don't think it would be worthwhile.