The aGorm can't code well Thread - Page 2

The aGorm can't code well Thread

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

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10312
Joined: 24 Jan 2006, 21:12

Re: The aGorm can't code well Thread

Post by PicassoCT »

FLOZi wrote:Speed is a float so that should be fine. Picasso is probably on the right track
Is there higher praise? Im dancing in my room right noaw... :D :mrgreen:
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

OK, just did a test, if the speed is above 1, it works fine, if the speed is less, it stops and starts. It's not going over hills or anything, it's flat ground. Can someone with some knowledge of how the engine works weigh in with a reason why it would do something so stupid? I mean, I dont compleatly mind doing the sort of hack Picassos on about, it's just would it would be better if I didn't have to.

aGorm
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: The aGorm can't code well Thread

Post by knorke »

have some units that do that too.
i think it is just Spring's pathing and certain combinations of speed/acceleration/brakerate/turnInPlace/... in the unitDef hat causes some units to do the StartMoving() StopMoving() spam.
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

More hunting, it seems to do it every 470/1000's of a second. Regardless of teh speed of the unit, as long as it's below 1. Changing the brakerate/acceleration seems to have no effect...

For now I'll just do a hack like Picassos, it will prob also solve the walk animation stoping when your changing destination, so might be a good odea anyway.

aGorm
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

Whats the difference between a local and not local function?

function stoptimer ()
local function stoptimer ()

For some reason "StartThread (stoptimer)" is only working when it's not a local function, but thats a bit weird as other threads are in local functions and work fine when called that way.

Is there a limit to the number of local functions?

aGorm
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: The aGorm can't code well Thread

Post by knorke »

when a function is local its definition must be further up then the line where it is called.
"not local" is called global.
that system not only applies to function but also to variables.
http://www.lua.org/pil/4.2.html
http://www.lua.org/pil/6.2.html
etc
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

Ahh... I see, it's below were i'm calling it. Should relly have spotted that, thanks.
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

Double post...

Code: Select all

[f=0005778] LuaRules::RunCallIn: error = 2, GameFrame, [string "LuaGadgets/Gadgets/unit_script.lua"]:745: attempt to index field '?' (a nil value)
stack traceback:
	[string "LuaGadgets/Gadgets/unit_script.lua"]:745: in function 'GameFrame'
	[string "LuaGadgets/gadgets.lua"]:936: in function <[string "LuaGadgets/gadgets.lua"]:934>
	(tail call): ?
What does this mean? I keep getting it randomly, nothing seem to have stoped working as far as I can see, but I assume somthing must be wrong?

::EDIT:: paste bin of unit script that is prob the cause http://pastebin.com/7nvbUGbX
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6175
Joined: 29 Apr 2005, 01:14

Re: The aGorm can't code well Thread

Post by FLOZi »

At a glance I don't see anything wrong with it, but your indenting makes it hard to read
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

Ok, so progress moves forward, and I've hit another problem.

Namly,

Code: Select all

buildoptions = 
	{
	"cyberfac",
	"cybergen",
	"cyberlord",
	},
For some reason this only gives me the build option to make the fac, not the gen or the lord. I know the lord should be buildable because the fac can build it and several other units fine. However thsi mobile builder only seems to be able to build the fac and nothign else.

I also know the gen unit works cause I can /give myself one and it comes out fine.

Is there somthign differnt between mobile and non-mobile builders that means that list won't work?

aGorm
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10312
Joined: 24 Jan 2006, 21:12

Re: The aGorm can't code well Thread

Post by PicassoCT »

look into the infolog, sometimes it says high above the usual errors, that a unit is taken from the productionlist of a factory -without stating any good reason for that.

May i take the liberty to ask in Addition:
http://springrts.com/wiki/Lua_SyncedRead
>>Spring.GetPlayerControlledUnit

is the tool of choice if you want to find out if "your" unit is the currently selected?

Also, how does one start soundfiles from unit.scripts. I know they have to be listed somewhere first, before they can be called. Just one line of example Code Sir, my scriptkids are starvin.

Oh, thank you Sir. thank you.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: The aGorm can't code well Thread

Post by knorke »

For some reason this only gives me the build option to make the fac, not the gen or the lord.
No idea really. Maybe try switching the order of the entries in buildoptions to see if something happens.
Is there somthign differnt between mobile and non-mobile builders that means that list won't work?
Don't think so.
Would need to look at whole unitdefs or mod...
>>Spring.GetPlayerControlledUnit
is the tool of choice if you want to find out if "your" unit is the currently selected?
that is to get what unit a player is currently FPS-controlling.
For selected units: http://springrts.com/wiki/Lua_UnsyncedR ... cted_Units

sounds:
http://springrts.com/wiki/Sounds.lua
http://springrts.com/wiki/Lua_UnsyncedCtrl#Sounds
Not sure if it works from unit scripts.
You are allowed to make new threads ;)
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10312
Joined: 24 Jan 2006, 21:12

Re: The aGorm can't code well Thread

Post by PicassoCT »

it thought if i would sacrifice my own phail in anothers thread, the wrath of the godz would strike down, and we both could use the electricity of the ligthning to get our train further forwards.

Explanation for wanting the sound:
Im sick of the phail that are my other scripts, so i decided to follow your example and to complete something simple. So i turned back to the motiondectector, and yeah, it works.

Did some research on how much heartbeats a relaxed human haz and how much a stressed, synchronized it with the beats, will grow the fear from the alienz inside the users.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14636
Joined: 17 Nov 2005, 02:43

Re: The aGorm can't code well Thread

Post by Forboding Angel »

aGorm wrote:Ok, so progress moves forward, and I've hit another problem.

Namly,

Code: Select all

buildoptions = 
	{
	"cyberfac",
	"cybergen",
	"cyberlord",
	},
For some reason this only gives me the build option to make the fac, not the gen or the lord. I know the lord should be buildable because the fac can build it and several other units fine. However thsi mobile builder only seems to be able to build the fac and nothign else.

I also know the gen unit works cause I can /give myself one and it comes out fine.

Is there somthign differnt between mobile and non-mobile builders that means that list won't work?

aGorm
Take the comma out form the last entry:

Code: Select all

buildoptions = 
	{
	"cyberfac",
	"cybergen",
	"cyberlord"
	},
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10312
Joined: 24 Jan 2006, 21:12

Re: The aGorm can't code well Thread

Post by PicassoCT »

Thx Forb, that solves alot of issues
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6175
Joined: 29 Apr 2005, 01:14

Re: The aGorm can't code well Thread

Post by FLOZi »

That shouldn't make any difference at all afaik?
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14636
Joined: 17 Nov 2005, 02:43

Re: The aGorm can't code well Thread

Post by Forboding Angel »

Shouldn't, but for reasons known only to god, it does. Happens in some other arrays as well, like in featureplacer random arrays it happens there too. Weird, but I just chalk it up to some logic that is too simple for my dumb ass to understand. Once you know it isn't that big of a deal anymore.
0 x

User avatar
AF
AI Developer
Posts: 20678
Joined: 14 Sep 2004, 11:32

Re: The aGorm can't code well Thread

Post by AF »

You can always put a comma after the last entry. These trailing commas are optional, but are always valid:

Code: Select all

    a = {[1]="red", [2]="green", [3]="blue",}
Such flexibility makes it easier to write programs that generate Lua tables, because they do not need to handle the last element as a special case.
Finally, you can always use a semicolon instead of a comma in a constructor. We usually reserve semicolons to delimit different sections in a constructor, for instance to separate its list part from its record part:

Code: Select all

    {x=10, y=45; "one", "two", "three"}
http://www.lua.org/pil/3.6.html

Javascript also has this but not quite the same. If you put a trailing comma, IE7 will freak out, old versions of firefox will assume you made a mistake, and everything else will follow the spec and place a null value as the last item in the array.
0 x

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: The aGorm can't code well Thread

Post by aGorm »

Sorry, I fixed this but never thought to post back here... it was actully a lot more simple. Nothing was wrong with the code. It was just I had a back up of teh file in a subdirectory of units, not realising it would load up any file in a sub over the one in the root...

aGorm
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6175
Joined: 29 Apr 2005, 01:14

Re: The aGorm can't code well Thread

Post by FLOZi »

aGorm wrote:Sorry, I fixed this but never thought to post back here... it was actully a lot more simple. Nothing was wrong with the code. It was just I had a back up of teh file in a subdirectory of units, not realising it would load up any file in a sub over the one in the root...

aGorm
This is why we ignore Forb, 8)


:P

btw picasso, fwiw, I would make a function PlayUnitSound(unitID, sound [, volume]) in a gadget;

Code: Select all

local function PlayUnitSound(unitID, sound, volume)
  local x,y,z = Spring.GetUnitPosition(unitID)
  local dx,dy,dz = Spring.GetUnitVelocity(unitID)
  Spring.PlaySound(sound, volume or 1, x,y,z, dx,dy,dz, "unitreply")
end

GG.PlayUnitSound = PlayUnitSound
Then in LUS:

Code: Select all

 local PlayUnitSound = GG.PlayUnitSound
...
PlayUnitSound(unitID, "sayhitoknorke")
0 x

Post Reply

Return to “Game Development”

cron