Editing W4M scripts : How to spawn a crate ?

For Boggy B and his mates. If they existed, of course.

Moderator: Dream17 Staff

Post Reply
User avatar
_Kilburn
Settled in
Posts: 58
Joined: Wed Aug 30, 2006 3:47 pm
Location: NULL

Editing W4M scripts : How to spawn a crate ?

Post by _Kilburn » Sun Oct 01, 2006 7:33 pm

Hi, i'm almost sure that nobody will answer my question but... I'm trying to make some funny game modes by modifying stdvs.lua (I have some knowledges about Lua). And I made a simple function that spawns a crate at a random position:

Code: Select all

function lib_QuickSpawnCrate(CrateContainerData)
    SendMessage("GameLogic.ResetCrateParameters")
    SetData("Crate.Type", CrateContainerData.Type)
    SetData("Crate.Contents", CrateContainerData.Contents)
    SetData("Crate.NumContents", CrateContainerData.NumContents)
    SetData("Crate.Index", CrateContainerData.Index)
    SetData("Crate.LifetimeSec", CrateContainerData.LifetimeSec)
    SetData("Crate.GroundSnap", CrateContainerData.GroundSnap)
    SetData("Crate.Parachute", CrateContainerData.Parachute)
    SetData("Crate.Spawn", CrateContainerData.Spawn)
    SetData("Crate.FallSpeed", CrateContainerData.FallSpeed)
    SetData("Crate.Gravity", CrateContainerData.Gravity)
    SetData("Crate.TeamDestructible", CrateContainerData.TeamDestructible)
    SetData("Crate.TeamCollectable", CrateContainerData.TeamCollectable)
    SetData("Crate.UXB", CrateContainerData.UXB)
    SetData("Crate.Hitpoints", CrateContainerData.Hitpoints)
    SetData("Crate.Pushable", CrateContainerData.Pushable)
    SetData("Crate.RandomSpawnPos", CrateContainerData.RandomSpawnPos)
    SetData("Crate.CanDropFromChute", CrateContainerData.CanDropFromChute)
    SetData("Crate.WaitTillLanded", CrateContainerData.WaitTillLanded)
    SetData("Crate.TrackCam", CrateContainerData.TrackCam)
    SetData("Crate.Scale", CrateContainerData.Scale)
    SetData("Crate.AddToWormInventory", CrateContainerData.AddToWormInventory)
    SetData("Crate.CustomGraphic", CrateContainerData.CustomGraphic)
    SendMessage("GameLogic.CreateCrate")
end
But how can I spawn a crate at a wanted position? I found a Crate.ExplicitSpawnPos property in Local.xml, but it is a VectorResource, so I can't modifiy it, neither with SetData, nor with EditContainer.
GetData("Crate.ExplicitSpawnPos") and QueryContainer("Crate.ExplicitSpawnPos") return nil. (nil is a Lua value which means NULL)
I dumped all variables with "for key,value in pairs(getfenv()) do ... end" and i don't see any function with "Vector" in its name.

And i would like the same thing for creating particle emitters, explosions and triggers.

If someone answers to my question, it would be extraordinary...

(sorry I'm so lazy, I just copy/paste from my post on Team17 forum)

User avatar
AndrewTaylor
Regular
Posts: 157
Joined: Tue Mar 01, 2005 11:01 am
Location: Leeds UK
Contact:

Post by AndrewTaylor » Sun Oct 15, 2006 5:37 pm

Do you think you could make a databank xml and import that?

K^2
Regular
Posts: 216
Joined: Thu May 26, 2005 4:02 am

Post by K^2 » Sun Oct 15, 2006 7:43 pm

I know there are some entities in the map files that can be used to point to various camera and spawn locations. I'm not sure if that's how crate spawns work, though.

Edit: If you know a map where the crate spawns at a certain location, I might be able to disect it.
None of my projects (Minus One converter, W3D/W4 Map Viewer, and WMapEditor) are endorsed, supported or otherwise affiliated with Dream17. I just find Dream17 forums to be a nice place to share and discuss my work with others.

Post Reply