Micha Posted January 6, 2015 Share Posted January 6, 2015 (edited) Hello I am planning to extend the mouseover from "widgets/uiclock", adding the time left in the current season. I succesfully did this to Dont Starve using onFocus and values from SeasonManager(). But it seems like DST does not have the class at all. I tried to circumvent this problem and call for season.lua:NUIClock.UpdateWorldString = function (self) self._text:SetString(NUISeasons._season:value()) self._showingcycles = falseendObviously, I had no luck. So Im devastatingly searching for a way to get equivalents for .daysleft and .currentSeason. Any Idea? Edited January 6, 2015 by Micha Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/ Share on other sites More sharing options...
przemolsz Posted January 6, 2015 Share Posted January 6, 2015 You can use TheWorld.state variables. Those which you're looking for areTheWorld.state.seasonandTheWorld.state.remainingdaysinseason Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-597733 Share on other sites More sharing options...
Kzisor Posted January 6, 2015 Share Posted January 6, 2015 @przemolsz, I was just about to post here, got ninja'd. @Micha, you can get the remaining days in a season by listening for the WorldState "remainingdaysinseason". Here is some example code. local function UpdateDaysRemaining(inst)-- TODO: Implement the update code.endlocal fn(inst)inst:WatchWorldState("remainingdaysinseason", UpdateDaysRemaining)return instend Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-597736 Share on other sites More sharing options...
Micha Posted January 7, 2015 Author Share Posted January 7, 2015 (edited) That solved my problem, thank you Please allow me some followup questions: - Searching my filesystem for "theworld" didnt show up anything. How- / Can I dig into the fields and functions of "TheWorld"? - Why didnt my example work? Cant I call stuff from /components/ or did I just do wrong? - I am unexperienced in writing code for games. How do you guys search for data sources in general? I grep'ed the files for relevant Strings, trying to find a context and then just try to call->extend the class or override the function. Am I on the wrong lane here? Edited January 7, 2015 by Micha Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-598144 Share on other sites More sharing options...
przemolsz Posted January 7, 2015 Share Posted January 7, 2015 -TheWorld is an instance of "world" prefab, that's where you should look; "scripts/prefabs/world"- How did you get the "NUISeasons" object?- I do the same, just code-digging. But I'm definitely not an experienced coder. Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-598263 Share on other sites More sharing options...
Micha Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) local NUISeasons = require "components/seasons"local NUIClock = require "widgets/uiclock"As NUIClock is a valid object, I thought i found a proper way of loading class instances that are singletons. Obviously not. Digging more through the forums, I now have seen this way as well:local hounded = GLOBAL.TheWorld.components.hounded.instprint(hounded:GetDebugString())print(hounded._timetoattack)Prints are a valid debug String and a nil. .inst seems to be designed to hold the single instance of hounded to be accesible, and the debug String does work as well. Accessing the local field however does not work (I guess because its local *facepalm*). Overwriting GetDebugString() and telling him to just return me _timetoattack should work, but by paying the price of loosing some internal code. Sorry for ranting^^ I guess my general problem is that I dont understand how to load the different types of objects, related to their scopes. The ways seem to differ. Edited January 8, 2015 by Micha Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-598681 Share on other sites More sharing options...
rezecib Posted January 9, 2015 Share Posted January 9, 2015 (edited) local hounded = GLOBAL.TheWorld.components.hounded.instIn this case, hounded == TheWorld. In a component, inst usually refers back to the entity that the component is attached to. Remove inst from the end there and you should get the output you're looking for. Edit: I would argue that generally when approaching at least DST's Lua code, Objects are not that useful a concept. It's more helpful to just think in terms of tables, because that's all that objects are, once they're constructed. Edited January 9, 2015 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/48525-i-need-various-functions-from-seasonmanager/#findComment-599093 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now