Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

simplex

[Code] A Thread On Lambdas And Other Epsilons

Recommended Posts

debugman18    1,112

So I'm working on this addition. It doesn't seem to do the trick though. @simplex, do you know of a way to confirm that the player is indeed loading a cloud level?

 

--This gives us custom worldgen screens.    local function UpdateWorldGenScreen(self, new_level_type, world_gen_options)    --Check for cloudrealm.    "cloudrealm"        if world_gen_options == new_level_type or "cloudrealm" then            --Changes the background during worldgen.        self.bg:SetTexture("images/bg_up.xml", "bg_plain.tex")        self.bg:SetTint(100, 100, 100, 1)                --The shadow hands can be changed.        --[[        local hand_scale = 1.5        self.hand1:GetAnimState():SetBuild("creepy_hands")        self.hand1:GetAnimState():SetBank("creepy_hands")        self.hand1:GetAnimState():SetTime(math.random()*2)        self.hand1:GetAnimState():PlayAnimation("idle", true)        self.hand1:SetPosition(400, 0, 0)        self.hand1:SetScale(hand_scale,hand_scale,hand_scale)                self.hand2 = self.bottom_root:AddChild(UIAnim())        self.hand2:GetAnimState():SetBuild("creepy_hands")        self.hand2:GetAnimState():SetBank("creepy_hands")        self.hand2:GetAnimState():PlayAnimation("idle", true)        self.hand2:GetAnimState():SetTime(math.random()*2)        self.hand2:SetPosition(-425, 0, 0)        self.hand2:SetScale(-hand_scale,hand_scale,hand_scale)            --]]        STRINGS.UI =        {            CLOUDGEN = {                            VERBS =                {                    "Wrangling",                    "Generating",                    "Herding",                    "Embiggening",                    "Iterating upon",                    "Insinuating",                    "Reticulating",                    "Inserting",                    "Framing",                },                                NOUNS=                {                    "clouds",                    "sheep",                    "candy",                    "giants",                    "snowflakes",                    "oxygen",                    "static",                    "castles",                    "beans",                    "nature",                        },            },        }                --We can replace the worldgen animation and strings.        --self.worldanim:GetAnimState():SetBuild("generating_cave")        --self.worldanim:GetAnimState():SetBank("generating_cloudrealm")        self.worldgentext:SetString("GROWING BEANSTALK")            self.verbs = GLOBAL.shuffleArray(STRINGS.UI.CLOUDGEN.VERBS)        self.nouns = GLOBAL.shuffleArray(STRINGS.UI.CLOUDGEN.NOUNS)        --TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/cloudGen", "worldgensound")            endendAddClassPostConstruct("screens/worldgenscreen", UpdateWorldGenScreen)

Share this post


Link to post
Share on other sites
simplex    2,607

@debugman18

local Pred = wickerrequire 'lib.predicates'if Pred.IsCloudLevel() then    --[[ ... ]]end
But it won't work, regardless of detection. The worldgen screen is created before any mods are loaded.

The way it goes is gamelogic.lua -> worldgenscreen.lua -> worldgen_main.lua, and it is only worldgen_main which loads mods. I think we can change the screen, but if so it'll probably require TheFrontEnd:PopScreen()'ing the regular one and then TheFrontEnd:PushScreen()'ing a customized one.

Share this post


Link to post
Share on other sites
simplex    2,607

It worked without popping the original screen?!

(maybe something changed in the new update, I had in fact tried that under Nightmares)

Share this post


Link to post
Share on other sites
debugman18    1,112

It worked without popping the original screen?!

(maybe something changed in the new update, I had in fact tried that under Nightmares)

It worked perfectly. :3

Share this post


Link to post
Share on other sites
debugman18    1,112

Is that in our main.lua or worldgen_main.lua?

Our main.lua. I'm using AddClassPostConstruct to do it. (Same thing with the mainscreen.)

Share this post


Link to post
Share on other sites
simplex    2,607

Our main.lua. I'm using AddClassPostConstruct to do it. (Same thing with the mainscreen.)

(Unless I'm mistaken, AddClassPostConstruct also exists when modworldgenmain.lua runs.)

Oooh, now I see what's going on. And why my attempt failed (I was assuming the screen already existed, I didn't try a postconstruct at all). I was basing myself on what Ipsquiggle explained at the lava cave thread, since that's a part of the game execution that switches back and forth with the engine, so I couldn't really track the execution flow just by reading the Lua code. The worldgenscreen is shown in the main menu state, and in the background the game creates another execution thread, which starts the worldgen environment and does the real thing. I never realized this game had real parallel execution (even if it seems to only happen here).

EDIT: Yay, my likes resetted!

Share this post


Link to post
Share on other sites
simplex    2,607

Wow, I hadn't seen that "Edited by JoeW" in the OP. I'm scared. What did he do?

(ok, that's probably related to enabling title editing)

Share this post


Link to post
Share on other sites
lifemare    314

0x4SVZv.gif

 

"Rendering rainbows"

"Decompressing fluffiness"

 

I'm giggling in antecipation after seeing that.

This mod is coming to life!

Share this post


Link to post
Share on other sites
simplex    2,607

"Rendering rainbows"

"Decompressing fluffiness"

 

I'm giggling in antecipation after seeing that.

This mod is coming to life!

See? All we needed was a badge. ;P

Share this post


Link to post
Share on other sites
simplex    2,607

@debugman18

I fixed the unresponsiveness of the UI after closing the credits screen. It was a silent crash (logged in log.txt), caused by STRINGS.UI being replaced as a whole. It was the same issue you were having when defining prefab names, remember?

EDIT


I was thinking about how to represent the "team data" in a way easy to maintain. My first idea was to store them directly in an AUTHORS.md file, to be used in the repo code browser, the GitHub Page and in the mod by implementing a Markdown processor. However, there's the issue that Markdown is a presentation language, so the contribution type (such as "code", "art", "writing" and "collaboration") would be directly referenced by its "human readable" name, i.e. by its screen description. This is far from ideal, because it would mean changing this would require changin the code as well to match the new name.

So I think the ideal format would be Lua itself (in an AUTHORS.lua file), which could then very easily be converted into Markdown for use elsewhere (a Makefile would be the ideal tool for doing that). I imagine AUTHORS.lua as something like this:

return {	{"code", {		title = "Coders",				"debugman18",		"simplex",	}},	{"art", {		title = "Artists",				"lifemare",		--[[ etc. ]]--	}},	--[[ etc. ]]--}
What do you think?

Additionally, we should decide if we want to print names within a category in a fixed order or if we want to randomly shuffle them (as in Klei's credits), and if we want to randomly shuffle categories as well. I like the idea of shuffling both, as long as the category for "miscellaneous contributions" is treated as an exception and kept last (in particular because it spans multiple pages).

Share this post


Link to post
Share on other sites
debugman18    1,112

@debugman18

I fixed the unresponsiveness of the UI after closing the credits screen. It was a silent crash (logged in log.txt), caused by STRINGS.UI being replaced as a whole. It was the same issue you were having when defining prefab names, remember?

EDIT


I was thinking about how to represent the "team data" in a way easy to maintain. My first idea was to store them directly in an AUTHORS.md file, to be used in the repo code browser, the GitHub Page and in the mod by implementing a Markdown processor. However, there's the issue that Markdown is a presentation language, so the contribution type (such as "code", "art", "writing" and "collaboration") would be directly referenced by its "human readable" name, i.e. by its screen description. This is far from ideal, because it would mean changing this would require changin the code as well to match the new name.

So I think the ideal format would be Lua itself (in an AUTHORS.lua file), which could then very easily be converted into Markdown for use elsewhere (a Makefile would be the ideal tool for doing that). I imagine AUTHORS.lua as something like this:

return {	{"code", {		title = "Coders",				"debugman18",		"simplex",	}},	{"art", {		title = "Artists",				"lifemare",		--[[ etc. ]]--	}},	--[[ etc. ]]--}
What do you think?

Additionally, we should decide if we want to print names within a category in a fixed order or if we want to randomly shuffle them (as in Klei's credits), and if we want to randomly shuffle categories as well. I like the idea of shuffling both, as long as the category for "miscellaneous contributions" is treated as an exception and kept last (in particular because it spans multiple pages).

 

I like the idea of shuffling both of them. I don't think any sub-group or collaborator should have priority over the others. (And misc contributions should definitely remain last, but the names shuffled.)

 

And yeah, that STRINGS.UI thing. I ran into that issue with the worldgen stuff, and changed it to STRINGS.UPUI and all was well. I just forgot to do the same thing to the modcredits. (Right now it's the same as the Klei credits, I hope to change that some.)

Share this post


Link to post
Share on other sites
simplex    2,607

I like the idea of shuffling both of them. I don't think any sub-group or collaborator should have priority over the others. (And misc contributions should definitely remain last, but the names shuffled.)

 

And yeah, that STRINGS.UI thing. I ran into that issue with the worldgen stuff, and changed it to STRINGS.UPUI and all was well. I just forgot to do the same thing to the modcredits. (Right now it's the same as the Klei credits, I hope to change that some.)

Ok, I'll do that right now. (details such as the shuffling should still be discussed among all in the Hub, but that can be changed from a first implementation)

Share this post


Link to post
Share on other sites
simplex    2,607

Small tweak: I made the upandaway_charge/uncharge event listener from the StaticChargeable component be removed automatically when the component is, in anticipation of things like permanent daturas.

Share this post


Link to post
Share on other sites
simplex    2,607

@TheDanaAddams

Sorry to bother you about this again, but I wrote a little Perl script to check for the presence of a few modules. Could you run it and post the output?

The executable permission of the script should preserved when unzipping it, so running it amounts to going to its directory with the terminal and typing "./featuretest.pl". Otherwise, "perl featuretest.pl" will run it (let me know if it's not directly executable).

For the time being, I'm going to write at least a Perl build renamer.

And I think I know why you're having issues when decompressing a build zip and then recompressing it. When creating an archive, Mac includes a folder with metadata for the files in there. So, for example, when unzipping your link mod I actually get two folder, the link one, and one called __MACOSX, which replicates the archive structure with metadata. I think that folder being included in the build zip is what's causing the game to complain.

featuretest.zip

Share this post


Link to post
Share on other sites
TheDanaAddams    574

Worked perfectly - ran from ./featuretest.pl without a hitch, and all came back OK. =)

 

Edit: In case you need it:

Last login: Sun Sep 15 01:10:48 on ttys000Danas-Mac-Pro:~ Rapunzel$ cd /Users/Rapunzel/DesktopDanas-Mac-Pro:Desktop Rapunzel$ ./featuretest.plChecking for module XML::LibXML... OKChecking for module XML::Simple... OKChecking for module File::Temp... OKChecking for module File::Copy... OKChecking for module Archive::Zip... OKChecking for module LWP::Simple... OKChecking for module LWP::UserAgent... OKChecking for module HTML::TreeBuilder... OKDanas-Mac-Pro:Desktop Rapunzel$

Share this post


Link to post
Share on other sites
simplex    2,607

Worked perfectly - ran from ./featuretest.pl without a hitch, and all came back OK. =)

 

Edit: In case you need it:

 

Last login: Sun Sep 15 01:10:48 on ttys000Danas-Mac-Pro:~ Rapunzel$ cd /Users/Rapunzel/DesktopDanas-Mac-Pro:Desktop Rapunzel$ ./featuretest.plChecking for module XML::LibXML... OKChecking for module XML::Simple... OKChecking for module File::Temp... OKChecking for module File::Copy... OKChecking for module Archive::Zip... OKChecking for module LWP::Simple... OKChecking for module LWP::UserAgent... OKChecking for module HTML::TreeBuilder... OKDanas-Mac-Pro:Desktop Rapunzel$

Wow. I really should adopt Perl as the main language for our team scripts, then. You have a very robust support over there. Even I didn't have Archive::Zip until earlier today. :razz:

(Archive::Zip allows things such as changing the inside of a zip without decompressing it, I looked into it precisely because of the issue you were having)

Share this post


Link to post
Share on other sites
simplex    2,607

@debugman18

I tweaked wicker to allow for mods defining their own extension of the wicker environment. Now, whatever is defined in scripts/upandaway/modenv.lua (and is not local) will act like a "global" variable in the wicker environment, but without actually touching the global environment.

Currently, I just defined a GetStaticGenerator() function there, in parallel to GetClock(), GetSeasonManager() and similar functions the game defines. It returns the StaticGenerator component of the world entity, so you can do things like GetStaticGenerator():IsCharged(), or GetStaticGenerator():Charge().

Share this post


Link to post
Share on other sites
TheDanaAddams    574

Ahaha, I actually found some information about using the terminal zip functions to add files to a zip without decompressing, but I just go the lazy route and do it with the BetterZip program.

 

I thought the zip issue was probably to do with the way Mac OS likes to include resource forks and stuff.

Share this post


Link to post
Share on other sites
simplex    2,607

@debugman18

I noticed you had added VERSION as an option, using it in main.lua. Under the wicker environment, you have access to the modinfo entries through TheMod.modinfo (and in main.lua/worldgen_main.lua that can be stated as just modinfo, because of the BindTheMod() call). So I erased that option and replaced your use of it with modinfo.version.

Share this post


Link to post
Share on other sites
debugman18    1,112

@simplex

Any ideas on making crops planted by Winnie grow in Winter?

 

I've looked at the related files, and it seems I need to counter MakeNotGrowableInWinter(). I'm not sure how to detect what is being planted at any given time. I suspect it has something to do with doer, however, since it involves ACTIONS.PLANT and plantables.lua.

 

MakeNotGrowableInWinter() detects the season and eventually does item.components.pickable:DoPause(), so even if I resume it, I'm assuming that would simply pause growing again.

Share this post


Link to post
Share on other sites