Jump to content

How can I find out what events are recognized by the game?


Recommended Posts

I'm making a mod that basically puts the slot machine from shipwrecked into don't starve together. The problem is, it won't accept payment and no hover option appears besides "examine." I believe this is because of an event in the slot machine's code that DST doesn't recognize called "acceptcurrency."

does anyone else agree this is most likely the problem, and if so, how would I fix it? is there another code I would need to add somewhere or something?

and if you don't think this is the problem, what else could be the issue?

Link to comment
Share on other sites

4 hours ago, CarlZalph said:

See trader component.

 

As for the thread title's question, do a find string in all the lua files for:  PushEvent("

That isn't the issue, the slot machine has its very own component, "payable" instead.

how would I be able to search for a line of code like that in ALL the shipwrecked lua files?

Link to comment
Share on other sites

3 minutes ago, mf99k said:

That isn't the issue, the slot machine has its very own component, "payable" instead.

how would I be able to search for a line of code like that in ALL the shipwrecked lua files?

"PushEvent" is used mostly in components, so you could open components you want to check and if you're using Notepad++, use ctrl+f to find this line...

Link to comment
Share on other sites

9 minutes ago, mf99k said:

That isn't the issue, the slot machine has its very own component, "payable" instead.

how would I be able to search for a line of code like that in ALL the shipwrecked lua files?

If you're trying to do a 1:1 port of the item in specific without using any of the already made assets DST has to offer, such as the trader component, then look in the lua script folder the shipwrecked mod has and port over the components it's using.

If I had to take a guess, then it's in a folderpath with DLC0002 as its name.

However, I just looked at a video showcasing this slot machine and the trader component would suffice in generating the callbacks required for what you're wanting to do.

 

As for doing a file search that really depends on your OS and envrionment.

If under Windows and using N++ then you can do a recursive find in files via Search->Find in Files...->Find what & Directory & In all sub-folders & Filters: *.lua.

Edited by CarlZalph
Filters: *.lua
Link to comment
Share on other sites

Just now, CarlZalph said:

If you're trying to do a 1:1 port of the item in specific without using any of the already made assets DST has to offer, such as the trader component, then look in the lua script folder the shipwrecked mod has and port over the components it's using.

If I had to take a guess, then it's in a folderpath with DLC0002 as its name.

However, I just looked at a video showcasing this slot machine and the trader component would suffice in generating the callbacks required for what you're wanting to do.

 

As for doing a file search that really depends on your OS and envrionment.

If under Windows and using N++ then you can do a recursive find in files via Search->Find in Files...->Find what & Directory & In all sub-folders.

I already ported the components it's using. The issue is that the game doesn't seem to recognize that it's supposed to accept gold from the player and I'm pretty sure this is either because the slot machine's prefab isn't communicating with the payable component correctly or that the game doesn't understand the payable component.

Link to comment
Share on other sites

acceptcurrency is being pushed in payable component. However I did not find any mention of ListenForEvent("acceptcurrency" anywhere, so the event itself looks like mod-friendly way to hook into it.

Searching for components.payable, it is used in slotmachine prefab, GIVE action and currency component.
I have no experience modding DS, thus I can only infer that DS's

function Currency:CollectUseActions(doer, target, actions)
    if target.components.payable and target.components.payable.enabled then
        table.insert(actions, ACTIONS.GIVE)
    end
end

is not compatible with the way DST collects actions. Maybe something like this would be a step towards solution:

AddComponentAction("USEITEM", "currency", function(inst, doer, target, actions, right)
    if target.components.payable and target.components.payable.enabled then
        table.insert(actions, ACTIONS.GIVE)
    end
end)

One has yet to solve the issue of components that are not existing on the client.

Link to comment
Share on other sites

21 hours ago, Muche said:

acceptcurrency is being pushed in payable component. However I did not find any mention of ListenForEvent("acceptcurrency" anywhere, so the event itself looks like mod-friendly way to hook into it.

Searching for components.payable, it is used in slotmachine prefab, GIVE action and currency component.
I have no experience modding DS, thus I can only infer that DS's


function Currency:CollectUseActions(doer, target, actions)
    if target.components.payable and target.components.payable.enabled then
        table.insert(actions, ACTIONS.GIVE)
    end
end

is not compatible with the way DST collects actions. Maybe something like this would be a step towards solution:


AddComponentAction("USEITEM", "currency", function(inst, doer, target, actions, right)
    if target.components.payable and target.components.payable.enabled then
        table.insert(actions, ACTIONS.GIVE)
    end
end)

One has yet to solve the issue of components that are not existing on the client.

I changed the code to currency as you said and now the game crashes when I approach the slot machine. Once again I'm having the nothing-in-the-error-logs problem. 

Link to comment
Share on other sites

17 hours ago, mf99k said:

I changed the code to currency as you said and now the game crashes when I approach the slot machine. Once again I'm having the nothing-in-the-error-logs problem. 

you sure ur looking in clientlog and not log right? cuz its highly unlikely to crash without a single line of error..

Link to comment
Share on other sites

4 hours ago, Aquaterion said:

you sure ur looking in clientlog and not log right? cuz its highly unlikely to crash without a single line of error..

yes, I looked in log, AND client_log AND all the cluster logs. The only thing that's been updating in client_log is all the commands I've been putting in console, and then the log just abruptly stops when the crash happens with no information. and none of the other logs seem to be updating at all.

This problem seems to have started around the time the game was last updated, so I feel it has something to do with that, but I have received errors for other crashes since then (but only on the crash warning screen)

Link to comment
Share on other sites

7 hours ago, Muche said:

Just wondering, are you testing this on hosted single-level world (i.e. only client_log  is updated), or hosted multi-level / dedicated server (client_log and server_logs are updated)?

I'm pretty sure the one I'm using is single-level, since the client_log has been updating and there are no caves

 

as a note, the keyboard on my modding computer is broken right now so I'm not gonna be able to test anything with the code until I get it fixed.

Edited by mf99k
Link to comment
Share on other sites

Changes:

- added payable tags on payable component on "enabled" member change, for client interaction

- moved AddComponentAction from currency.lua to modmain.lua, changed implementation to use tags

-- target with payable component will have "payable" tag if (target.components.payable and target.components.payable.enabled) is true
-- players make use of this check, so hosts and clients both need to be able to do it
-- the tag propagates through the network, so everybody can work with it
-- CollectUseActions and other action functions that fill up the playeractionpicker only work in single player, not DST

-- extended the give action to introduce currency functionality

-- the give function of the give action only takes care of the trader component, and not the currency one

- added network functionality to the prefab

-- lack of AddNetwork was likely the reason of the crashes without logs (RakNet missing replica error)

- added currency component to goldnugget prefab

-- the slot machine will accept the goldnugget, yes, but you can't give it to it, if it doesn't have the currency component
-- because it's no currency, so the component action doesn't apply

- commented out GetTreasureLootList for the SpawnReward function of the machine

-- it isn't defined or implemented yet, so it causes a crash, go work on it

 

slot machine.zip

Link to comment
Share on other sites

12 hours ago, DarkXero said:

Changes:

- added payable tags on payable component on "enabled" member change, for client interaction

- moved AddComponentAction from currency.lua to modmain.lua, changed implementation to use tags

-- target with payable component will have "payable" tag if (target.components.payable and target.components.payable.enabled) is true
-- players make use of this check, so hosts and clients both need to be able to do it
-- the tag propagates through the network, so everybody can work with it
-- CollectUseActions and other action functions that fill up the playeractionpicker only work in single player, not DST

-- extended the give action to introduce currency functionality

-- the give function of the give action only takes care of the trader component, and not the currency one

- added network functionality to the prefab

-- lack of AddNetwork was likely the reason of the crashes without logs (RakNet missing replica error)

- added currency component to goldnugget prefab

-- the slot machine will accept the goldnugget, yes, but you can't give it to it, if it doesn't have the currency component
-- because it's no currency, so the component action doesn't apply

- commented out GetTreasureLootList for the SpawnReward function of the machine

-- it isn't defined or implemented yet, so it causes a crash, go work on it

 

slot machine.zip

in other words everything except the treasure loot list works?

Link to comment
Share on other sites

26 minutes ago, mf99k said:

in other words everything except the treasure loot list works?

The stategraph didn't seem to have anything that clashed with DST.

The payable component didn't, either, in terms of functionality, as it is.

I could insert gold nuggets into the slot machine both as host and as client.

So that's a yes.

Link to comment
Share on other sites

Just now, DarkXero said:

The stategraph didn't seem to have anything that clashed with DST.

The payable component didn't, either, in terms of functionality, as it is.

I could insert gold nuggets into the slot machine both as host and as client.

So that's a yes.

anything in particular with the treasure loot list seem to be a problem? I'm not sure where to start

Link to comment
Share on other sites

2 minutes ago, mf99k said:

anything in particular with the treasure loot list seem to be a problem? I'm not sure where to start

treasurehunt.lua in scripts/map/ wasn't required. Thus, GetTreasureLootList is nil.

require("map/treasurehunt") and uncomment the line with GetTreasureLootList.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...