Page 1 of 1

Cancellable events

Posted: Sat Oct 17, 2015 7:48 pm
by maciekmm
Make cancelling events (reverting actions) possible. I'm aware this can cause many issues, but would be very handy to make protection mods for public servers for example.

Re: Cancellable events

Posted: Sat Oct 17, 2015 8:52 pm
by daniel34
I'm not sure what you mean by cancelling events / reverting actions. The gameplay in Factorio is deterministic, it reevaluates the game state 60 times per second. You can't just cancel one event/action and still continue with the game, because the outcome of that cancellation would render the future gamestates different, and therefore invalid. The only thing you can do is revert to an earlier autosave. Mods don't have the ability to do that (and probably never will).
How would these protection mods you are talking about work? What is their purpose? You can already protect a server by disabling console commands.
(Well, you could write a mod that prevents you from deconstructing the whole base or parts of it, but how do you know this action wasn't done on goodwill because they wanted to redo the layout?)

Re: Cancellable events

Posted: Sat Oct 17, 2015 9:26 pm
by Ranakastrasz
Sounds more like he wants to be able to register a particular action a player takes and if it meets some criteria, block it, or revert it or something.

Re: Cancellable events

Posted: Mon Jan 11, 2016 2:56 pm
by StanFear
yeah like being able, when an entity is being mined (in on_robot_pre_mined for instance) to be able to do something like envent.canceled = true

then the robot would not get the item, and the entity would still be there

obviously, all events can't be reversible, like on_train_changed_state

but only the actions made by the player and robots would be greate already !

Re: Cancellable events

Posted: Mon Jan 11, 2016 3:12 pm
by Klonan
maciekmm wrote:Make cancelling events (reverting actions) possible. I'm aware this can cause many issues, but would be very handy to make protection mods for public servers for example.
Theres no need for a separate event as there is a fairly simple way to implement this without cancelling the event (which can't be cancelled really because it happens in a single tick)

First there is forces support, which prevents mining of entities if they are from different forces (you can also set global mining speed for each force)
Second you can script so that when an entity is mined, you can check if the player mining it is the 'owner' of the entity, and if not, then place the entity back down where it was (and remove the mined item from the players inventory)

Re: Cancellable events

Posted: Wed Jan 13, 2016 5:32 pm
by StanFear
Klonan wrote:First there is forces support, which prevents mining of entities if they are from different forces (you can also set global mining speed for each force)
Second you can script so that when an entity is mined, you can check if the player mining it is the 'owner' of the entity, and if not, then place the entity back down where it was (and remove the mined item from the players inventory)
well there are these options obviously, but they are tedious to implement and could make a difference CPU wise, right ?

Re: Cancellable events

Posted: Thu Jan 14, 2016 11:01 am
by Klonan
StanFear wrote:
Klonan wrote:First there is forces support, which prevents mining of entities if they are from different forces (you can also set global mining speed for each force)
Second you can script so that when an entity is mined, you can check if the player mining it is the 'owner' of the entity, and if not, then place the entity back down where it was (and remove the mined item from the players inventory)
well there are these options obviously, but they are tedious to implement and could make a difference CPU wise, right ?
Well not really...

Theres also the option to make a small 'tool' an admin can hold in their hand, with this you can set entities to 'mineable = false' and 'destructible = false' to prevent griefing, this would be a pretty foolproof, easy and cpu efficient way to prevent trolls in your servers.