wiremod / advduplicator

Garry's Mod add-on that allows a player to save and load contraptions
http://www.wiremod.com
Apache License 2.0
67 stars 43 forks source link

Added hook when a player is starting to paste #58

Closed d-kuen closed 10 years ago

d-kuen commented 10 years ago

This hook gives the possibility to get the pasting player and the entity list on a very easy way. This hook fits perfectly to the already existing hook, when a player finished to paste a dupe.

I'm open for any suggestions or changes!

Thanks

Divran commented 10 years ago

You forgot delayed pasting: https://github.com/wiremod/advduplicator/blob/master/lua/autorun/server/advdupe.lua#L2055 right now, your hook will only run if you paste a small enough contraption that it doesn't turn into a delayed paste.

EDIT: Actually, maybe it would be better to run the hook from here https://github.com/wiremod/advduplicator/blob/master/lua/autorun/server/advdupe.lua#L1872

d-kuen commented 10 years ago

Ok I changed those 2 things. If there are any other suggestions, please send them to me. Thanks ;)

Divran commented 10 years ago

Change it from hook.Run("AdvDupe_StartPasting", AdvDupe, Player, NumOfEnts) to hook.Run("AdvDupe_StartPasting", Player, NumOfEnts) (remove the AdvDupe table), do the same for all hook.Runs. This is because the AdvDupe table is global anyway so we don't need to send it.

d-kuen commented 10 years ago

Ok, I did that now too.

I just did what you said before:

You forgot delayed pasting: https://github.com/wiremod/advduplicator/blob/master/lua/autorun/server/advdupe.lua#L2055 right now, your hook will only run if you paste a small enough contraption that it doesn't turn into a delayed paste. EDIT: Actually, maybe it would be better to run the hook from here https://github.com/wiremod/advduplicator/blob/master/lua/autorun/server/advdupe.lua#L1872

So I think this was not an error by me. I reverted it back so the StartPaste hook now only runs once in the "StartPaste" function.

Divran commented 10 years ago

When I said "Actually, maybe it would be better to run the hook from here" I meant ONLY from there.

Anyway, this looks fine now, merging