Jump to content

[Ideas 'n' such] New Adventure-ish Realm


Recommended Posts

* Hm, well uh, I copied the entire mod folder as it was without changing it in any way I'm pretty sure, but I can double check for good measures. EDIT: Yeah so, I can't see anything different at least..

* That's what I did the first time though, just copied the files over and started up the mod immediately.

I think this is the same problem I had before, some file is deleted in my spriter project and spriter doesn't want to forget about it. Cheerio helped me by replacing those with placeholders. I don't know what those deleted files could be called or anything though so I probably need his help again?

EDIT: No wait actually, uh, that time I could still open up the project on my windows and it would look fine, just not work fine. Now however it does neither.

It definitely looks like some art assets aren't being loaded. If you look on the left of the Windows screenshot, the thumbnails aren't there, while in the Mac screenshot, they are. I wonder if the system file structure changing (Win-Mac) has anything to do with that.

Link to comment
Share on other sites

It definitely looks like some art assets aren't being loaded. If you look on the left of the Windows screenshot, the thumbnails aren't there, while in the Mac screenshot, they are. I wonder if the system file structure changing (Win-Mac) has anything to do with that.

It's so strange that it worked before but not now. In any case, suppose that means the problem should be dealt with on spriter's own forums. How annoying :l

Meanwhile, I've started on my blueberries prefab. I can't make any sense out of the vanilla berrybush prefab, it's too confusing! And the vanilla berries themselves share their prefab with other veggies. And as before, that veggies prefab is kinda confusing too.. x) I need some help with setting the bush up. The difference of the blueberry bush to the vanilla is that they shouldn't spawn a gobbler, and doesn't need to be fertilized as they can't be dug up, neither should they have any indication on how many berry-stages there are left. Just a simple empty/full.

I can understand the other edible prefabs like petals etc though~ Should I set up my blueberries that way rather than trying to use the veggies prefab? It should work but I'm not sure of the pros of the veggies prefab, and cons of ignoring it.

Link to comment
Share on other sites

It's so strange that it worked before but not now. In any case, suppose that means the problem should be dealt with on spriter's own forums. How annoying :l

Meanwhile, I've started on my blueberries prefab. I can't make any sense out of the vanilla berrybush prefab, it's too confusing! And the vanilla berries themselves share their prefab with other veggies. And as before, that veggies prefab is kinda confusing too.. x) I need some help with setting the bush up. The difference of the blueberry bush to the vanilla is that they shouldn't spawn a gobbler, and doesn't need to be fertilized as they can't be dug up, neither should they have any indication on how many berry-stages there are left. Just a simple empty/full.

I can understand the other edible prefabs like petals etc though~ Should I set up my blueberries that way rather than trying to use the veggies prefab? It should work but I'm not sure of the pros of the veggies prefab, and cons of ignoring it.

The only pros of the veggie prefab is that all you only need one file, as opposed to many. It depends on your preferences, though. (Unless there are pros I don't know about.) However, it'd be good practice to familiarize yourself with the process.

 

Are you confused about this:

return createbush("berrybush"), createbush("berrybush2")

I can explain it. When you do

return createbush("prefab"), createbush("berrybush2")

you're calling the return value of the function createbush("prefab), which looks like a regular prefab constructor (usually called fn):

local function createbush(bushname)    local assets =    {        Asset("ANIM", "anim/"..bushname..".zip"),    }    local prefabs =    {        "berries",        "dug_"..bushname,        "perd",        "twigs",    }           local function fn(Sim)            local inst = CreateEntity()            --Snip Snip--            return inst        end    return Prefab( "common/objects/"..bushname, fn, assets, prefabs)    end

You see where it decides its return value:

return Prefab("common/objects/"..bushname, fn, assets, prefabs)

It's saying, create prefab under common/objects with the prefab name "bushname" (whatever you put inside of createbush(bushname)) with the constructor "fn", with the specified assets, and the specified prefabs.

 

Basically, everything you want to change is:

The assets and prefabs.

Changing 'fn' to your preferences for the berrybush.

Changing 'bushname' to whatever you want the bush to be called.

 

Or, if you don't want to deal with that, just take the constructor and use it as a regular prefab. As for the blueberries, just use any single food item as a base.

Link to comment
Share on other sites

The only pros of the veggie prefab is that all you only need one file, as opposed to many. It depends on your preferences, though. (Unless there are pros I don't know about.)

Well, the main reason for doing that is because vegetables share a lot of code, so by putting them in the same file they can use a common set of local functions.

I still with those common parts were isolated in "library" files and then require()'d, because from the modder's side it's a pain not being able to use them (since they're local).

Link to comment
Share on other sites

return createbush("prefab"), createbush("berrybush2")

you're calling the return value of the function createbush("prefab), which looks like a regular prefab constructor (usually called fn):

Hnnng. You've lost me already. I don't understand the "calling return value of the function" part. It's moments like these I question my hobby do mod things .-.

EDIT: I don't know what's the rudest thing to do here. Keep asking questions and try to learn things, but still not really learning or remembering them, thus forcing people to keep comming back until I kinda get it.

Or give up and ask for/demand finished codes from you guys.

I try to learn so that I can stop being a hassle, but I just can't shake off the feeling I'm still annoying :B

Link to comment
Share on other sites

Hnnng. You've lost me already. I don't understand the "calling return value of the function" part. It's moments like these I question my hobby do mod things .-.

EDIT: I don't know what's the rudest thing to do here. Keep asking questions and try to learn things, but still not really learning or remembering them, thus forcing people to keep comming back until I kinda get it.

Or give up and ask for/demand finished codes from you guys.

I try to learn so that I can stop being a hassle, but I just can't shake off the feeling I'm still annoying :B

No worries; you're not annoying. It's actually good to see a modder want to learn and expand their skills. Even if you fail, at least you're giving it a shot. I've seen a few modders on here not even try to improve.

 

As for the return value of the function, it's just a way of getting a particular bit of information. In this case, its the prefab information itself. In this case, doing

return createbush(bushname)

is the same thing as doing

return Prefab("common/objects/bushname", fn, assets, prefabs) 

Although if it's still a little confusing, I suggest just making a simpler prefab for it, using something like a marsh tree for a suitable base.

Link to comment
Share on other sites

EDIT: I don't know what's the rudest thing to do here. Keep asking questions and try to learn things, but still not really learning or remembering them, thus forcing people to keep comming back until I kinda get it.

Or give up and ask for/demand finished codes from you guys.

I try to learn so that I can stop being a hassle, but I just can't shake off the feeling I'm still annoying :B

I vote for you to stay annoying  ; P

Srsly though. If you get any sort of fun/enjoyment from modding then just keep asking for help. I think you should always ever only stop doing something when you're not getting any enjoyment or are hurting people with it. Since the latter is barely possible with what you're doing here I would suggest you decide for yourself  ^^

 

 

Hnnng. You've lost me already. I don't understand the "calling return value of the function" part. It's moments like these I question my hobby do mod things .-.

He's referring to the function he quotes bellow that. At the bottom  you see the part that says "return" something. The thing to the right of the return is the returnvalue of the function "createbush" and that is what is being called when you call the function and is thus what the file actually returns and it looks just like every other return of a prefab file. I think that was the essence of the post.

Now if the problem is with the usage of "calling" a function. That is codewise where you have a name and the brackets afterwards, like "createbush("berrybush2")". In words: You call the function berrybush with the argument "berrybush2".

 

Edit: Ninja'd  ^^

Link to comment
Share on other sites

is the same thing as doing

Oh, I think I understand it a bit better now.

 

I vote for you to stay annoying  ; P

Thank you two xD You can probably tell I'm very insecure about these things. I'll just continue :)

I mashed together bits of code, made a berrybush prefab and it's tex files should be there too. I tried to look into minimap icons but they seem bit tough, so I'll fix that in a bit. The berrybush should be "pickable" in a odd fashion, but I haven't set up the actions properly or the bush being able to look nor be empty.

With what I've got so far the game crashes, something I'm missing again. Could you check it out?

Test mod.zip

Link to comment
Share on other sites

Oh, I think I understand it a bit better now.

 

Thank you two xD You can probably tell I'm very insecure about these things. I'll just continue :-)

I mashed together bits of code, made a berrybush prefab and it's tex files should be there too. I tried to look into minimap icons but they seem bit tough, so I'll fix that in a bit. The berrybush should be "pickable" in a odd fashion, but I haven't set up the actions properly or the bush being able to look nor be empty.

With what I've got so far the game crashes, something I'm missing again. Could you check it out?

Log?

Link to comment
Share on other sites

There's a comma after createbush("blueberry_bush") that shouldn't be there in scripts/prefabs/blueberry_bush.lua.

You were right :-)

It says now blueberry_bush.lua:5: variable 'bushname' is not declared though. I knew there would be some more things that I was missing.

I included the entire mod in post #83 if anyone else want to see the prefab's etc

EDIT: Just to make it clear. Declaring the bushname sounds easy and probably is, but I actually don't know how to fix it x)

Link to comment
Share on other sites

You were right :-)

It says now blueberry_bush.lua:5: variable 'bushname' is not declared though. I knew there would be some more things that I was missing.

I included the entire mod in post #83 if anyone else want to see the prefab's etc

EDIT: Just to make it clear. Declaring the bushname sounds easy and probably is, but I actually don't know how to fix it x)

The fix for that error would be to change the first line to:

local function createbush(bushname)
But, the createbush function is actually unnecessary in your case; wrapping everything in a function is only necessary when you want to create more than one nearly-identical prefab in the same file. Check out most other prefab files for an example of defining a single prefab in a file, but in your case, you can remove the 'local function createbush(blueberry_bush)' line, change 'local function bush()' to 'local function fn()', and remove the last two lines ('end' and 'return createbush("blueberry_bush")'). Then change 'return Prefab( "common/objects/"..bushname, fn, assets, prefabs)' to 'return Prefab( "common/objects/blueberry_bush", fn, assets, prefabs)'
Link to comment
Share on other sites

There's actually a few more changes needed. Try this:

local assets = {	Asset("ANIM", "anim/blueberry_bush.zip"),}local prefabs ={	"blue_berries",	--"dug_"..bushname,  --(The bush isn't supposed to be dug up, so I don't need this do I?)	"twigs",}local function fn()	local inst = CreateEntity()	local trans = inst.entity:AddTransform()	local anim = inst.entity:AddAnimState()	local minimap = inst.entity:AddMiniMapEntity()	--local <span class="searchlite">minimap</span> = inst.entity:Add<span class="searchlite">MiniMap</span>Entity()	--<span class="searchlite">minimap</span>:SetIcon( "blueberry_bushicon.tex" ) --You'll probably recognize this, let's see if I can make it work	--inst:AddTag("bush")	--minimap:SetIcon( bushname..".png")	MakeObstaclePhysics(inst, .1)	anim:SetBank("blueberry_bush")	anim:SetBuild("blueberry_bush")	anim:PlayAnimation("idle", false)	inst:AddComponent("pickable")	inst.components.pickable.picksound = "dontstarve/wilson/harvest_berries"	inst.components.pickable:SetUp("blue_berries", TUNING.BERRY_REGROW_TIME)	MakeLargeBurnable(inst)	MakeLargePropagator(inst)	inst:AddComponent("lootdropper") --Will I need this? Isn't the loot if you dig up the bush, yeah?	inst:AddComponent("inspectable")	inst.components.inspectable.nameoverride = "Blueberry Bush"	return instendreturn Prefab( "common/objects/blueberry_bush", fn, assets, prefabs)

Note that you will probably need to change the line 'anim:SetBank("blueberry_bush")' to the right bank for your anim ("berrybush" I would assume).

Link to comment
Share on other sites

But, the createbush function is actually unnecessary in your case

 

Hm, I do plan on making two different kinds of bushes though, that are "nearly-identical".

 

Like so;

z7SKrHN.png

Note that you will probably need to change the line 'anim:SetBank("blueberry_bush")' to the right bank for your anim ("berrybush" I would assume).

 

Isn't the bank the spriter file for custom anim-things? If I use "berrybush" it would look like the vanilla bush wouldn't it?

Link to comment
Share on other sites

Hm, I do plan on making two different kinds of bushes though, that are "nearly-identical".

 

Like so;

z7SKrHN.png

Ah, didn't realize that. In that case, I'll try to explain what the createbush function does:

Calling createbush will set the parameters to the values you give it, so doing:

 

local function createbush( bushname )    print( bushname )endcreatebush( "test" )
will call the function, and, inside the function, it will set a variable with the name of the first parameter (bushname) to the value that you gave it ("test"). So, the code above would print "test".

Return values are the things that the function gives back to you when you call it.

local function testreturnfn( teststr )    return string.lower( teststr )endlocal return_value = testreturnfn( "TEST" )print( return_value )
The code above would print "test".

So, in your case, you want to define a function that takes as parameters all the things that would be different between the prefabs. The function would then use those parameters to set up a prefab as normal, and then return a Prefab object. If you call the createbush function multiple times, you will get back a new Prefab object each time.

This code should work (but is untested):

local function createbush( prefabname, name, berries )	local assets = 	{		Asset("ANIM", "anim/"..prefabname..".zip"),	}	local prefabs =	{		berries,		--"dug_"..bushname,  --(The bush isn't supposed to be dug up, so I don't need this do I?)		"twigs",	}	local function fn()		local inst = CreateEntity()		local trans = inst.entity:AddTransform()		local anim = inst.entity:AddAnimState()		local minimap = inst.entity:AddMiniMapEntity()		--inst:AddTag("bush")		--minimap:SetIcon( prefabname..".png")		MakeObstaclePhysics(inst, .1)		anim:SetBank( prefabname )		anim:SetBuild( prefabname )		anim:PlayAnimation("idle", false)		inst:AddComponent("pickable")		inst.components.pickable.picksound = "dontstarve/wilson/harvest_berries"		inst.components.pickable:SetUp(berries, TUNING.BERRY_REGROW_TIME)		MakeLargeBurnable(inst)		MakeLargePropagator(inst)		inst:AddComponent("lootdropper") --Will I need this? Isn't the loot if you dig up the bush, yeah?		inst:AddComponent("inspectable")		inst.components.inspectable.nameoverride = name		return inst	end	return Prefab( "common/objects/"..prefabname, fn, assets, prefabs)endreturn createbush( "blueberry_bush", "Blueberry Bush", "blue_berries" )

 

Isn't the bank the spriter file for custom anim-things? If I use "berrybush" it would look like the vanilla bush wouldn't it?

I haven't kept up on how people create prefab textures these days, so what I said might no longer be relevant. Other people would be able to give you a better answer about this.
Link to comment
Share on other sites

Ah, didn't realize that.

Okay wow, thanks :-) The code doesn't crash or anything, but spawning in a blueberry bush with console commands makes the game go nuts.

The UI goes away, so no inventory. Opening chests makes their inventory appear far left on the screen. Hovering over objects doesn't give any information but you can still interact. And of course, the bush itself isn't even visible.

It's the oddest thing I've seen yet. If anyone wants to see what's going on I've included the mod as a zip again, use the command c_spawn("blueberry_bush") on the console to test it out. Just be careful playing with it on any world you might like though.

Test mod.zip

Link to comment
Share on other sites

Okay wow, thanks :-) The code doesn't crash or anything, but spawning in a blueberry bush with console commands makes the game go nuts.

The UI goes away, so no inventory. Opening chests makes their inventory appear far left on the screen. Hovering over objects doesn't give any information but you can still interact. And of course, the bush itself isn't even visible.

It's the oddest thing I've seen yet. If anyone wants to see what's going on I've included the mod as a zip again, use the command c_spawn("blueberry_bush") on the console to test it out. Just be careful playing with it on any world you might like though.

I'm not sure why you keep changing the first parameter of createbush to blueberry_bush. You shouldn't be doing that. Or, if you want to change a parameter's name, you have to change all of the references to that parameter as well. See my previous post for the reason why. Understanding how functions and variables work is so incredibly important. I'd really suggest getting familiar with those concepts.

The code I gave you seems to work fine. However, inspectable.nameoverride does not actually do what you were trying to use it for (and I was unfamiliar with it so I just went along with it). To get a name of something, the game will look it up in the STRINGS table based on the prefab name. Setting nameoverride will just make inspectable get the string as if the prefab had the name of the value of nameoverride.

Here is a 100% working and tested prefab file:

local function createbush( prefabname, berries )    local assets =    {        Asset("ANIM", "anim/"..prefabname..".zip"),    }     local prefabs =    {        berries,        --"dug_"..bushname,  --(The bush isn't supposed to be dug up, so I don't need this do I?)        "twigs",    }	    local function fn()        local inst = CreateEntity()        local trans = inst.entity:AddTransform()        local anim = inst.entity:AddAnimState()        local minimap = inst.entity:AddMiniMapEntity()         --inst:AddTag("bush")        --minimap:SetIcon( prefabname..".png")         MakeObstaclePhysics(inst, .1)         anim:SetBank( prefabname )        anim:SetBuild( prefabname )        anim:PlayAnimation("idle", false)         inst:AddComponent("pickable")        inst.components.pickable.picksound = "dontstarve/wilson/harvest_berries"        inst.components.pickable:SetUp(berries, TUNING.BERRY_REGROW_TIME)         MakeLargeBurnable(inst)        MakeLargePropagator(inst)         inst:AddComponent("lootdropper") --Will I need this? Isn't the loot if you dig up the bush, yeah?         inst:AddComponent("inspectable")         return inst    end     return Prefab( "common/objects/"..prefabname, fn, assets, prefabs)end-- every key in the STRINGS table should be in all caps-- note that this STRINGS stuff doesn't have to be in this file; it can be anywhere, reallySTRINGS.NAMES.BLUEBERRY_BUSH = "Blueberry Bush"STRINGS.CHARACTERS.GENERIC.DESCRIBE.BLUEBERRY_BUSH = "That is a blueberry bush." return createbush( "blueberry_bush", "blue_berries" )
Link to comment
Share on other sites

I'm not sure why you keep changing the first parameter of createbush to blueberry_bush.

 

Oh okay, sorry! :/ I thought I was meant to, "prefabname" sounds very tutorial-like, as if you could replace it with your own naming. And I suppose I could if I just then rename every prefabname after that as well you say? I'll just leave it for now though.

Anyway thank you so much :)

I'll keep working on different things and finish more artwork now~ If I get stuck I'll get back here.

Link to comment
Share on other sites

Oh okay, sorry! :/ I thought I was meant to, "prefabname" sounds very tutorial-like, as if you could replace it with your own naming. And I suppose I could if I just then rename every prefabname after that as well you say? I'll just leave it for now though.

Anyway thank you so much :-)

I'll keep working on different things and finish more artwork now~ If I get stuck I'll get back here.

Strings not wrapped in quotes are variable names.

prefabname = "value"othervariable = prefabname
sets the value of the variable named prefabname to the string "value", and then sets the value of the variable othervariable to the value of the prefabname variable ("value"). Changing variable names is only necessary under somewhat rare circumstances and usually is done when the purpose of the variable changes, as good variable names are descriptive of what they are used for/what type of value they hold.
Link to comment
Share on other sites

Very kind of you sir, but I don't think this needed a 'Bump' : P

Cosheeta will come here when he needs us, I'm sure.

Hello sure, I'm Cosheeta.

I managed to add a map icon to my bushes thanks to your tutorial btw :grin: I feel so pro. I have also messed about with custom sounds, and gotten a bit forward with few minor problems.

Ehum.

A list... of few minor problems~

Vanilla chess pieces attack the rats, is bad. I've added a chess tag to the rats, but it doesn't seem to do anything but making them play a fancy metallic "bonk" noise once they're hit.

Custom sound is played at full volume at any position, no stereo. This could be because of the files?

Scml file for rat is broken. Can't add further animations. I think I need to call Cheerio for wizardry help?

Blueberry bush needs empty animation. Not sure how to add. Also a entire new animation set for the 'other kind of bush'.

Walls prefab file is like anything else confusing. I could do with some basic explaining so that custom walls can be added :razz:

Streetlights will have their own "campfirefire" prefab presumably called "streetlightlight" cannot however understand campfirefire's or firepit's prefab files on how to do sooooooo. *Aauugh*

Here's my mod file, in case anyone is up for a bit of testing. Test mod.zip

Link to comment
Share on other sites

A list... of few minor problems~

Vanilla chess pieces attack the rats, is bad. I've added a chess tag to the rats, but it doesn't seem to do anything but making them play a fancy metallic "bonk" noise once they're hit.

Custom sound is played at full volume at any position, no stereo. This could be because of the files?

Scml file for rat is broken. Can't add further animations. I think I need to call Cheerio for wizardry help?

Blueberry bush needs empty animation. Not sure how to add. Also a entire new animation set for the 'other kind of bush'.

Walls prefab file is like anything else confusing. I could do with some basic explaining so that custom walls can be added :razz:

Streetlights will have their own "campfirefire" prefab presumably called "streetlightlight" cannot however understand campfirefire's or firepit's prefab files on how to do sooooooo. *Aauugh*

Here's my mod file, in case anyone is up for a bit of testing. attachicon.gifTest mod.zip

That's a big list  xD  I only have time for a few now.

 

As far as the rat being targeted by the chess pieces you might find something helpful inside the KeepTarget and ReTarget functions of the chesspieces. I think the "chess" tag plays some role with that.

 

In my custom character sound tutorial is a file attached that is right from the devs which should have options resembling the ingame sounds. You migt be able to snag some tidbits there.

 

The berrybush has a lot of different animations, the one for an empty bush is "empty". You can find all inside of "berrybush.lua" and since your blueberrybush is based off of that you can probably use all the same animation names.

 

For getting a streetlight you don't necessarily need a fire prefab. If I remember correctly the thing is electric so you'll just need the light. You can find examples in the heatstone for example.

 

You can mess with the ideas and hints and come back when you need more precise help. I just don't have time to sift through code right now  ; )

Link to comment
Share on other sites

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.

×
  • Create New...