Jump to content

Recommended Posts

I don't get it:

I am rewritting pretty much from scratch a mod to dig out sinkholes (e.g. create caves). I know you can do it in console but what's the fun in that ? ^^

Mainly because all mods I found on the subject overwrite cave_entrance.lua & therefore have a bunch of issues, since there's at least 2 versions of it, depending on DLC. So the goal was for the sinkhole to not be covered by rock so I got this idea :

temprecipe = GLOBAL.Recipe("cave_entrance.open", {Ingredient("rope", 20)}, RECIPETABS.TOWN,  TECH.NONE, "cave_entrance_placer")

the strange thing, is "cave_entrance.open"  worked ... once. Since then I had image/atlas/string problems and strangely this does not work anymore

when you place it, the character says : "I can't do that". "cave_entrance" works but places the rock on it which you will dig out & recover lots of ingredients used for construction.... plus it doesn't make much sense to dig out access to the underworld, and then place a rock on it to dig it out again xD

Edited by whismerhill
Link to comment
https://forums.kleientertainment.com/forums/topic/70489-recipe-weirdness/
Share on other sites

after trying again & again I must have dreamed that it worked one time...

So I'm trying to go the dummy prefab way : here's the result

everything is working, got recipe, text, image, placer but on placing the recipe I get the error message (in console, doesn't crash DS)

Spoiler

scripts/mainfunctions.lua(145,1) Failed to spawn    cave_entrance_dummy

here's the content of cave_entrance_dummy.lua :

require "prefabutil"
local function onbuilt(sim) 
	local item = SpawnPrefab("cave_entrance")
	-- _G.cave_entrance.Open(item)
	--inst:remove()
end
return Prefab ( "cave_entrance_dummy", onbuilt, nil, nil), MakePlacer( "common/cave_entrance_placer", "cave_entrance", "cave_entrance", "idle_open" )

as you can see there's some commented out stuff. I'm trying to make the dummy work first & foremost ^^. Have a hard time finding examples of dummy prefabs out there :p

44 minutes ago, whismerhill said:

haaaaa return is not my friend I'm afraid xD. Thanks a bunch this dummy prefab now works, just need to Open it now lol (which is the whole point of its existence)

inst.components.workable:WorkedBy(GetPlayer(), inst.components.workable.workleft)

GetPlayer() is exclusive to singleplayer, it won't work in DST, but you could easily work around that using the "onbuilt" event.

Thanks. replaced "inst" with "item" and it works right away.

So in fact this code makes the player do the action I want to do, but instantly. Interesting... the whole time I wanted to execute a function located in the prefab, or apply to it a property.

 "getplayer" & "work" on the generated prefab is a completely different approach xD

I'll try to keep this outlook on stuff in mind in the future.

Edited by whismerhill

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
×
  • Create New...