attack parameters and moving objects.

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

attack parameters and moving objects.

Post by Dysoch »

can it be made possible that attack parameters can be added to cars or trains?

the game now wont startup now if you try to add the parameters to cars.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: attack parameters and moving objects.

Post by slpwnd »

At the moment this is not possible. Also it is not obvious how would this work with regular weapons - like when you are in the car now you can shoot from your selected weapon.

User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: attack parameters and moving objects.

Post by Dysoch »

Shame, really wanted to make tanks ;)

I know you can shoot in a car, but weapons mounted on a car are more stronger.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: attack parameters and moving objects.

Post by FreeER »

Dysoch wrote:Shame, really wanted to make tanks ;)
I know you can shoot in a car, but weapons mounted on a car are more stronger.
You could (fairly easily) use control.lua to swap out the player's weapons with a new (uncraftable) 'tank cannon' when the player enters the tank. Then they'd be able to use it just like they would their typical weapons. Of course, make sure that you reswap the weapons when they get out :)

Should be able to do something similar to this

Code: Select all

intank = false -- boolean
playerguns = nil
playerammo = nil
game.ontick(function()
if game.player.vehicle and (game.player.vehicle.name == "tank") then
  intank = true
  playerguns = util.table.deepcopy(game.player.character.getinventory(defines.inventory.playerguns))
  playerammo = util.table.deepcopy(game.player.character.getinventory(defines.inventory.playerammo))
  game.player.character.getinventory(defines.inventory.playerguns).clear()
  game.player.character.getinventory(defines.inventory.playerammo).clear()
  game.player.character.getinventory(defines.inventory.playerguns).insert{name="tankcannon", count="1"}
  game.player.character.getinventory(defines.inventory.playerammo).insert{name="tankshells", count="100000"} --this depends on how high you set the stack count
end
if not game.player.vehicle or not (game.player.vehicle.name == "tank") and intank then --if player was in tank and now is not
  intank = false
  game.player.character.getinventory(defines.inventory.playerguns).clear()
  game.player.character.getinventory(defines.inventory.playerammo).clear()
  game.player.character.getinventory(defines.inventory.playerguns) = playerguns
  game.player.character.getinventory(defines.inventory.playerammo) = playerammo
end
end)
-- note util.table.deepcopy gave error in console, I think this will work in a script though
--I had issues testing this due to the deepcopy above, simply setting playerguns=getinventory fails because it makes playerguns simply another name for the current playerguns inventory. To return weapons you may need to do a for _, gun in ipairs(playerguns) do getinv.insert{name=gun.name, count=gun.count} end, I couldn't test if you could simply set the inventory=playerguns
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Post Reply

Return to “Modding interface requests”