Adding units to maps, unit does not get found cuz movedef

Adding units to maps, unit does not get found cuz movedef

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

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

Adding units to maps, unit does not get found cuz movedef

Post by knorke »

I want to add a unit to a map, like Speedballs does with the superfusion.
The unit works when included in a game.
So I move over all the files from the unit to the map like this:

RoadMap4.sdd\
Ôö£ÔöÇÔöÇÔöÇmaps
Ôöé RoadMap4.smd
Ôöé Roadmap4.smf
Ôöé Roadmap4.smt
Ôöé
Ôö£ÔöÇÔöÇÔöÇobjects3d
Ôöé Van_White.s3o
Ôöé
Ôö£ÔöÇÔöÇÔöÇscripts
Ôöé tpcivvehicle.lua
Ôöé
Ôö£ÔöÇÔöÇÔöÇunits
Ôöé whitevan.lua
Ôöé
ÔööÔöÇÔöÇÔöÇunittextures
Van.dds

But on trying to spawn it:
[f=0000128] /give whitevan
[f=0000128] Couldnt find wreckage info whitevan
[f=0000128] whitevan is not a valid unitname

There is no error in infolog but if you want to see youself: http://pastebin.com/nKg3c9AC
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Adding units to maps (unit does not get found)

Post by jK »

BA does not use lua scripts?
Neither for UnitDefs nor LUS.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps (unit does not get found)

Post by knorke »

BA :roll:
but just found out it actually is something else in the unitDef:
MovementClass = "Vehicle2x2",
That movedef does not exist in other games and so does not work.

How can I add new moveDefs via the map?
Can they be declared in the unitdef file, like with weapons?

Just copying in a gamedata\movedefs.lua overwrites the mods's movdefs.lua and breaks all non-building/flying units.
I want the map to work with "all" mods so can not use "KBOT2" or something.

Also should I just put the unitscript.lua thing into the map or would that not be good?

will a unitdef_post.lua overwrite the file from the mod?
too late today to test, testing tomorrow.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps, unit does not get found cuz movedef

Post by knorke »

Also should I just put the unitscript.lua thing into the map or would that not be good?
ok, appearently having a
Map.sdd\LuaRules\Gadgets\unit_script.lua
in the map is no problem with mods that already have it.

Now with the movedef thing...?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Adding units to maps, unit does not get found cuz movedef

Post by Jools »

It's not a problem, but I imagine it could be if you have two units with the same name but different functions.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Adding units to maps, unit does not get found cuz movedef

Post by smoth »

probably because unlike scripts, movedefs are integral to pathing.

Knorke, make a new config map_movedefs.. customize modefs_post to add your defs as well..

as far as dealing with conflicts:

KnorkTank2x2 = def
KnorkWaffle4x5 = def

etc

that should resolve the issue. if you have issues let me know, I already dick with movedefs in gundam and can write something up for you tonight(about 6-7 hours from now)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps, unit does not get found cuz movedef

Post by knorke »

Jools wrote:It's not a problem, but I imagine it could be if you have two units with the same name but different functions.
yes, that is why its good to prefixes on the names of stuff, will do for this too later. but problem here is def. the movementclass thing.
Knorke, make a new config map_movedefs
putting a map_movedefs.lua had no result - it might as well not be there.
.. customize modefs_post to add your defs as well..
i could do that but if i put a movedefs_post.lua in the game (or map, same result) it seems to be ignored?
I tried an empty file with just
Spring.Echo ("movedefs_post.lua from GAME!")
and it prints nothing to infolog.txt

For unitdefs_post.lua that works with Spring.Echo ("unitdefs_post.lua FROM GAME!")
Not sure if movedefs_post simply can not echo or if it is not found.
Annoying stuff is annoying.
I am off now but probally later in lobbychat
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Adding units to maps, unit does not get found cuz movedef

Post by smoth »

I may have done some extra work to add a _post ;)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Adding units to maps, unit does not get found cuz movedef

Post by jK »

defs.lua fails in many ways currently. engine patches are welcome.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Adding units to maps, unit does not get found cuz movedef

Post by smoth »

>:D really...
so if someone did something like the goober who added subdirectory support for unitdefs... it would be accepted?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps, unit does not get found cuz movedef

Post by knorke »

jK wrote:defs.lua fails in many ways currently. engine patches are welcome.
does that imply it is currently not possible?
or just that it needs stupid workarounds?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Adding units to maps, unit does not get found cuz movedef

Post by jK »

there is no way to w/o breaking future compatiblity
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps, unit does not get found cuz movedef

Post by knorke »

hm, i think if the map breaks with next engine version i will just make a v2.
Unless 0.83 is released tommorrow I think it is worth it.
So how would it be done?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Adding units to maps, unit does not get found cuz movedef

Post by jK »

you need to override defs.lua, currently no game does so afaik, so no game related data is lost (atm).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Adding units to maps, unit does not get found cuz movedef

Post by knorke »

Did not find a defs.lua in any game i looked at so that might work.

Not sure how to edit defs.lua though.
It seems there needs to be something like
DEFS.moveDefs = LoadDefs('moveDefs')
DEFS.moveDefs = LoadDefs('moveDefs_map')

and somehow change LoadDefs to not override but add the loaded defs?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Adding units to maps, unit does not get found cuz movedef

Post by smoth »

you don't need to.. to do what you need would take me 10 minutes. I looked at it this morning. but apparently a bigger change needs to happen so, I am waiting on JK to give me details on what he wants for the refactor. I will be working very very late today so I cannot look into it tonight.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Adding units to maps, unit does not get found cuz movedef

Post by zwzsg »

jK wrote:you need to override defs.lua, currently no game does so afaik, so no game related data is lost (atm).
I override defs.lua in all games I touch.

Mainly because I dislike having to split my "_post" .lua code between separate files for weapons, feature, weapons, and find it much more useful when, for units generated by code, the weapons and wrecks is generated along. Otherwise, I'd have to duplicate lots of code into three _post.lua files, and that'd be messy.

I use something like that: http://pastebin.com/asvGGZRM

That way anydefs_post.lua can contains code that modify all defs at once.

Except recently I added my special modoption to end all modopoptions, the one that let players rebalance anything from the battlerooms. And I felt it should be in a separate file cause it's mod agnostic, so defs.lua would need to look a bit like that: http://pastebin.com/zQS7WUi2
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Adding units to maps, unit does not get found cuz movedef

Post by smoth »

[19:21:07] <smoth> is zwzsg's combined def what you wanted?
[19:22:13] <[LCC]jK> yup, he did 2 things I wanted
[19:22:29] <[LCC]jK> 1. he created the DEFS table before calling LoadDefs
[19:22:54] <[LCC]jK> 2. ye add that anydefs_post.lua (I would just name it defs_post.lua)
[19:23:06] <[LCC]jK> but 1. is bugged in his code
..
[19:23:25] <smoth> how should it work
[19:23:28] <[LCC]jK> he need to merge the results of LoadDefs
..
[19:24:01] <smoth> how should that be resolved?
..
[19:25:41] <[LCC]jK> so the code should look like this: table.merge(DEFS.unitDefs, LoadDefs('unitDefs'))
..
[19:26:04] <smoth> oh there is a table.merge?
[19:26:15] <smoth> I had no idea we had that
[19:26:40] <[LCC]jK> nah, but I wrote it like hundred times in my code ;)
[19:27:44] <[LCC]jK> function table:merge(table2)
[19:27:45] <[LCC]jK> for i,v in pairs(table2) do
[19:27:45] <[LCC]jK> if (type(v)=='table') then
[19:27:45] <[LCC]jK> local sv = type(self)
[19:27:45] <[LCC]jK> if (sv == 'table')or(sv == 'nil') then
[19:27:45] <[LCC]jK> if (sv == 'nil') then self = {} end
[19:27:45] <[LCC]jK> table.merge(self,v)
[19:27:45] <[LCC]jK> end
[19:27:45] <[LCC]jK> elseif (self == nil) then
[19:27:45] <[LCC]jK> self = v
[19:27:45] <[LCC]jK> end
[19:27:45] <[LCC]jK> end
[19:27:45] <[LCC]jK> end
..
[19:40:49] <[LCC]jK> problem with z's code is: issue #1 needs to get fixed (needs to use table.merge), 2nd needs better name than anydefs_post.lua (you won't be able to change that afterwards)
[19:41:00] <[LCC]jK> 3rd map needs to integrated
[19:41:22] <[LCC]jK> so z's code is like 20% of what needs to be done
[19:41:25] <smoth> mind if I copy paste these bits into the thread?
[19:41:31] <[LCC]jK> np
[19:41:40] <smoth> cool
..
[19:42:00] <[LCC]jK> in total the current code has these three issues:
[19:43:03] <[LCC]jK> 1. any _post.lua script should be able to create any type of defs (-> create DEFS table before calling LoadDefs & use table.merge)
[19:43:14] <[LCC]jK> 2. needs a new defs_post.lua
[19:43:23] <[LCC]jK> 3. needs map integration


so hey z, would it be trouble to make the 3 alterations?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Adding units to maps, unit does not get found cuz movedef

Post by zwzsg »

I don't really understand jK. He says 1. is bugged but I don't understand how. To be honest I barely understand what goes on in defs.lua. I just changed what seemed to be needed to be changed to let me have what I wanted, and I'm confident it somehow works, since I'm successfully using it to:
- Modify existing units and weapons
- Create new units and weapons

But of course, that it works doesn't mean it's perfect.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Adding units to maps, unit does not get found cuz movedef

Post by jK »

you do

Code: Select all

DEFS.armorDefs   = LoadDefs('armorDefs')
that overrides anything in DEFS.armorDefs that was created in LoadDefs('unitDefs')
Post Reply

Return to “Map Creation”