Don't Starve Together

Don't Starve Together

Rowing
Minor Bug, Mod incompatibilities caused by Rowing
Hello Hime,

Muche and I found a minor bug in your rowing mod, which can cause incompatibilities with other mods that change the code of functions or that create function interfaces.

First, lets have a look at the class definition of Action found in line 16 and below in actions.lua:
Action = Class(function(self, data, instant, rmb, distance, ghost_valid, ghost_exclusive, canforce, rangecheckfn)
and then we notice, that the function calls can be given additional arguments.

Now, lets have a look at, for example lines 366-373 of rowings modmain.lua:
ACTIONS.COOK.fn_before_rowing = ACTIONS.COOK.fn
ACTIONS.COOK.fn = function(act)
local orig = ACTIONS.COOK.fn_before_rowing(act)
if orig and act.again then
generic_repeat(act, simple_repeat, nil)
end
return orig
end

This definition of COOK doesn't carry over the possible additional parameters. In case of cook, there can be given a data, lets call it 'reason' which in case of an action-failure determines which entry of ACTIONFAIL.COOK will be said by the character. If that parameter is lost, only ACTIONFAIL.COOK.GENERIC will be said, instead of the actually called phrase.

It will probably be the same with EAT, where characters should have different phrases depending on the quality or the type of food. And of course, with all other actions, that make use of those additional arguments.

For cooking, I do have this quick fix:
ACTIONS.COOK.fn_before_rowing = ACTIONS.COOK.fn
ACTIONS.COOK.fn = function(act)
--local orig = ACTIONS.COOK.fn_before_rowing(act)
local orig, reason = ACTIONS.COOK.fn_before_rowing(act)
if orig and act.again then
generic_repeat(act, simple_repeat, nil)
end
--return orig
return orig, reason
end

Instead of dropping the data argument, it is passed over to 'reason', which is returned together with the function.

I'm not sure though whether this solution works for "data" only, or if this covers the whole argument table. Of course, a solution which passes over the whole argument table would be more elegant, as it could be used for all actions, instead of having many different cases.


So, why is this a bug?
My character is supposed to return certain dialogue lines, when the player is trying to perform certain actions. If the player is using the rowing mod, the arguments for these dialogue lines are discarded by the function interfaces (like the given example) in rowing and then only the generic messages (in case of actionfail or eat) or none will be shown.
Without rowing, the arguments are passed through the function interfaces and the character talks to the player as intended.
< >
Showing 1-2 of 2 comments
hime  [developer] 10 Jul, 2016 @ 12:21pm 
You meant to say I was discarding the return value, probably... Anyway, I'm fixing it now...
hime  [developer] 10 Jul, 2016 @ 12:42pm 
I fixed the bug but the mod uploader is crashing when I try to upload it to DST... it went fine into DS...
< >
Showing 1-2 of 2 comments
Per page: 1530 50