models then what? - Page 3

models then what?

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
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: models then what?

Post by FLOZi »

Note that there are 4 types of lua (well, actually, there are more, but there are 4 main types for a fresh-out-the-box modder to concern themselves with) :wink:
  • Gadgets - (Mostly) Synced code, these implement your own game logic, they go in LuaRules/Gadgets directory.
  • Widgets - (Mostly) Unsynced code, generally UI elements and related things (like formation move orders), they go in LuaUI/Widgets directory.
  • Animations - These are unit animations, a new addition to replace the old TA BOS/COB animations, they go in Scripts directory (well, that is the de facto standard).
    N.B. lua animations are actually in 'gadget space' by which I mean they have access to the same callouts as gadgets which lets you do some nifty things once you know what you're doing and is why lua anims are superior to BOS/COB
  • Defs - Weapon, features and unit defs, go in Weapons, Features and Units directories respectively, these are just a big table of tags which control your unit and weapon attributes.
    (N.B. It is quite common to combine weapon and (corpse) feature defs into the unit def)
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: models then what?

Post by aGorm »

Quick question... assuming that your unitdef and movedef's are correct, should your unit need a script to move about? (I mean, sure I know it will act as one solid lump, but should the solid lump be able to move about?)
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: models then what?

Post by Pressure Line »

you need a script. but you dont really need a heck of a lot in there.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: models then what?

Post by FLOZi »

If its cob it just needs the Create(), though it won't self destruct properly without a Killed(). A lua anim can be totally blank, but the file needs to exist.
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: models then what?

Post by aGorm »

humm, well the blank lua file exists... so maybe I have somthing wrong in my def's... I'll post them up when I get back...
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

My units move around with a blank lua script. They don't shoot and they are not animated. I still can't get this stupid lua script right...
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

http://pastebin.com/m52a9ace6 This is what i think is my animation lua. It's called "hovertank" and it's in the scripts folder. My tank is still not behaving correctly. I'm sure my script is wrong or not complete but i don't know how to fix it. Any suggestions?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: models then what?

Post by Tobi »

You're using a variable (piece?) 'body' in QueryWeapon, AimWeapon and Killed, but it's not declared anywhere.

Also note that in the script you can use Spring.Echo(...) statements to display debugging output on the in game console. (and in infolog.txt)
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

After changing my code, i'm still not getting my unit to fire or look animated. Am I correct in my assumption that there are, at the bare minimum, two files that are supposed to animate the unit and control how it fires? The two files i'm referring to are the file in the scripts folder and the file in the units folder.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: models then what?

Post by Pressure Line »

yes. it needs a weapon.

Code: Select all

  weapons             = {
    {
      def                = [[LIGHTNING]],
      badTargetCategory  = [[FIXEDWING]],
      onlyTargetCategory = [[FIXEDWING LAND SINK SHIP SWIM FLOAT GUNSHIP HOVER]],
    },

  },


  weaponDefs          = {

    LIGHTNING      = {
      name                    = [[LightningGun]],
      areaOfEffect            = 8,
      beamWeapon              = true,
      craterBoost             = 1,
      craterMult              = 2,
      cylinderTargetting      = 0,

      damage                  = {
        default = 160,
        planes  = 160,
        subs    = 8,
      },

      duration                = 10,
      explosionGenerator      = [[custom:LIGHTNINGPLOSION]],
      fireStarter             = 50,
      impactOnly              = true,
      impulseBoost            = 0,
      impulseFactor           = 0.4,
      intensity               = 12,
      interceptedByShieldType = 1,
      lineOfSight             = true,
      noSelfDamage            = true,
      range                   = 280,
      reloadtime              = 1.8,
      renderType              = 7,
      rgbColor                = [[0.5 0.5 1]],
      soundHit                = [[lashit]],
      soundStart              = [[lghthvy1]],
      soundTrigger            = true,
      startsmoke              = [[1]],
      targetMoveError         = 0.3,
      texture1                = [[lightning]],
      thickness               = 10,
      turret                  = true,
      weaponType              = [[LightingCannon]],
      weaponVelocity          = 400,
    },
  },
example from CA
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

I'm sorry if this seems increasingly lazy of me but i just want to show you the state of my two files. Because it's to my limited understanding that I have everything in working order. It's just not animated or firing though, it's just driving around. Here is my file that goes in the scripts folder: http://pastebin.com/m36ab3670 Here is my file that's in my units folder: http://pastebin.com/m3f5faeb5 . Both are called "hovertank".
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: models then what?

Post by Pressure Line »

Code: Select all

function script.AimWeapon1( heading, pitch )
Signal( aim )
SetSignalMask( aim )
return true
end
for a unit to look animated, you have to animate it ;)

eg:

Code: Select all

function script.AimWeapon1( heading, pitch )
Signal( aim )
SetSignalMask( aim )
        Turn(turret, y_axis, heading, math.rad(90))
        Turn(barrel, x_axis, -pitch, math.rad(50))
        WaitForTurn(turret, y_axis)
        WaitForTurn(barrel, x_axis)
return true
end
thats assuming you have a unit thats set up like this:
Image

otherwise you will have to pop back into your modeling suite, export the pieces separately and re-form them in upspring
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

[img=http://img193.imageshack.us/img193/5475 ... gss.th.png]

Still no luck after implementing your suggestions. Should my math.rad values be different since my tank is not exactly like yours?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: models then what?

Post by FLOZi »

Those values are simply rotational speed
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: models then what?

Post by Pressure Line »

Nothing to do with that. I couldnt get lua unit scripts to work either...

*Pressure Line wanders back off to bosland and burbles happily
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

So does Lua work?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: models then what?

Post by FLOZi »

It works fine. Do you have the required gadget lua to activate lua unit anim scripts?

http://spring1944.svn.sourceforge.net/v ... iew=markup

Is an example of the required code. Put it in the LuaRules/Gadgets directory of your mod.

(N.B. Really all you need is a gadget that has the [code]return include("LuaGadgets/Gadgets/unit_script.lua")[/code] line in it)
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

I added that widget but it made no difference. Are they other things i'm not aware of? Is there any part of what i have that someone would like to examine?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: models then what?

Post by Tobi »

Check in infolog.txt that it is loaded properly.

There should be lines like this:
[ 0] Loading gadget: Lua unit script framework <unit_script.lua>
[ 0] Loading unit script: scripts/gbr/tanks/gbrchurchillmkvii.lua
[ 0] Loading unit script: scripts/gbr/tanks/gbrcromwell.lua
[ 0] Loading unit script: scripts/gbr/tanks/gbrcromwellmkvi.lua
...snip...
[ 0] Loaded gadget: Lua unit script framework <unit_script.lua>
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: models then what?

Post by oksnoop2 »

http://pastebin.com/m18430f7b

This is my infolog.txt A week ago my game was not loading because it could not find the laser ..something or other. So i had to drag and drop some stuff from CA into it and it started up. Folders I pulled are:
gamedata
bitmaps
luarules

Is there a file in these folders that is undermining what i'm trying to do?
Post Reply

Return to “Game Development”