Limiting Weapon use in zone

Place to get help with not working mods / modding interface.
abregado
Former Staff
Former Staff
Posts: 282
Joined: Sat Aug 30, 2014 9:43 am
Contact:

Limiting Weapon use in zone

Post by abregado »

Im working on some scripts for a modified version of Factorio to use in schools and holiday programs. The next step is to be able to define zones in the control.lua for a scenario in which the players are not allowed to fire weapons, activate capsules/grenades, or drive vehicles.

Stopping players from driving inside an area is trivial using the teleport function but the weapon removal/disable is a bit trickier.

My first ideas were:
When players enter these zones strip them of the items and then return them upon leaving the area
or
Remove the equipped slots from players inside the areas
or
replace weapons with "dummy versions when entering zones, and replace them again when leaving zones

Is there a way to intercept the fire keypress or capsule deployment?
How can I store confiscated items that persists across loads/server restarts?
Can anyone think of a better way to do this?
jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: Limiting Weapon use in zone

Post by jorgenRe »

If you can't disable the use you can confiscate items and store them in a global table example
D = 2

Does not persist, but
Global.D = 2
Will ;)!

Defining the zones could probably be done by checking for an item with no texture or collision.
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces
abregado
Former Staff
Former Staff
Posts: 282
Joined: Sat Aug 30, 2014 9:43 am
Contact:

Re: Limiting Weapon use in zone

Post by abregado »

Ive got the zones working well so far.

So anything added to the Global object will be stored on save and retrieved on load?
jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: Limiting Weapon use in zone

Post by jorgenRe »

abregado wrote:Ive got the zones working well so far.

So anything added to the Global object will be stored on save and retrieved on load?
Yes :)!
Trye this:

Code: Select all

if (global.dd == null) then
global.dd = 1
end

Then in the on load function
global.dd += 10

THen in the on_tick 
game.players[0].print(global.dd)
Now this should print an increasing number that increases by 1 for every load since it will only set global.dd to 1 if it does not exist, but since its a global variable it should stay!
PS if you arent already aware of it if you only change the script you will only need to reload the save, not the whole game :)!
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces
Post Reply

Return to “Modding help”