Jump to content

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


Recommended Posts

Can you post the entire prefab again?

 

Edit: Or is that the only line changed?

It should be the only line changed apart from a shadow, bit of rescaling and world collision added

--[TUTORIAL] Here we list any assets required by our prefab.local assets={	--[TUTORIAL] this is the name of the Spriter file.	Asset("ANIM", "anim/rat.zip"),}--[TUTORIAL] This function creates a new entity based on a prefab.local function init_prefab()	--[TUTORIAL] First we create an entity.	local inst = CreateEntity()	--[TUTORIAL] Then we add a transform component se we can place this entity in the world.	local trans = inst.entity:AddTransform()	--[TUTORIAL] Then we add an animation component which allows us to animate our entity.	local anim = inst.entity:AddAnimState()	local shadow = inst.entity:AddDynamicShadow() --[WORKS NOW] Trying to add a shadow here	shadow:SetSize( 1.5, .75 )	MakeCharacterPhysics(inst, 50, .5)	inst.Physics:CollidesWith(COLLISION.WORLD)		--[TUTORIAL] The bank name is the name of the Spriter file.    anim:SetBank("rat")    --[TUTORIAL] The build name is the name of the animation folder in spriter.    anim:SetBuild("rat")    --[TUTORIAL] Here we start playing the 'idle' animation and tell it to loop.    anim:PlayAnimation("idle", true )    anim:SetScale( 1.25, 1.25 )    --inst.AddComponent("inspectable") --[HELP] Not working (Made these two into comments because they where not working)    --inst.components.inspectable.nameoverride = "Clockwork Pawn"    --[NEW] return our new entity so that it can be added to the world.    return instend--[NEW] Here we register our new prefab so that it can be used in game.return Prefab( "monsters/rat", init_prefab, assets, nil)

Link to comment
Share on other sites

It should be the only line changed apart from a shadow, bit of rescaling and world collision added

--[TUTORIAL] Here we list any assets required by our prefab.local assets={	--[TUTORIAL] this is the name of the Spriter file.	Asset("ANIM", "anim/rat.zip"),}--[TUTORIAL] This function creates a new entity based on a prefab.local function init_prefab()	--[TUTORIAL] First we create an entity.	local inst = CreateEntity()	--[TUTORIAL] Then we add a transform component se we can place this entity in the world.	local trans = inst.entity:AddTransform()	--[TUTORIAL] Then we add an animation component which allows us to animate our entity.	local anim = inst.entity:AddAnimState()	local shadow = inst.entity:AddDynamicShadow() --[WORKS NOW] Trying to add a shadow here	shadow:SetSize( 1.5, .75 )	MakeCharacterPhysics(inst, 50, .5)	inst.Physics:CollidesWith(COLLISION.WORLD)		--[TUTORIAL] The bank name is the name of the Spriter file.    anim:SetBank("rat")    --[TUTORIAL] The build name is the name of the animation folder in spriter.    anim:SetBuild("rat")    --[TUTORIAL] Here we start playing the 'idle' animation and tell it to loop.    anim:PlayAnimation("idle", true )    anim:SetScale( 1.25, 1.25 )    --inst.AddComponent("inspectable") --[HELP] Not working (Made these two into comments because they where not working)    --inst.components.inspectable.nameoverride = "Clockwork Pawn"    --[NEW] return our new entity so that it can be added to the world.    return instend--[NEW] Here we register our new prefab so that it can be used in game.return Prefab( "monsters/rat", init_prefab, assets, nil)

Ah, found it. :razz:

 

It should be inst:AddComponent() not inst.AddComponent().

 

Edit: In case it is hard to see, the issue is the ':' not being there, since it's trying to run a function.

Link to comment
Share on other sites

Ah, found it. :razz:

 

It should be inst:AddComponent() not inst.AddComponent().

AUGH xD I make the silliest mistakes, I'm usually so much more careful writing codes I swear.

Okay so the game isn't crashing woop, I can mouse over the creature yay, but even though I've set a nameoverride it's called MISSING NAME. And the hitbox for examining the creature is really really tiny, at his feet, it's like the shadow is his hitbox?

5DNXRjU.png

Thank you very much btw :)

Link to comment
Share on other sites

AUGH xD I make the silliest mistakes, I'm usually so much more careful writing codes I swear.

Okay so the game isn't crashing woop, I can mouse over the creature yay, but even though I've set a nameoverride it's called MISSING NAME. And the hitbox for examining the creature is really really tiny, at his feet, it's like the shadow is his hitbox?

Thank you very much btw :-)

For a bigger mod it's probably more convenient to create a file for all your strings instead of overwriting every string directly in the prefab.

EWSTRINGS = {	NAMES = {            RAT = "Clockwork Vermin",	},	CHARACTERS = {		GENERIC = {			DESCRIBE = {				RAT = "Look, it's a rat!",			},		},		WILLOW = {		},		WOLFGANG = {		},		WOODIE = {		},		WICKERBOTTOM = {		},		WENDY = {		},		WX78 = {		},		WAXWELL = {		},	},}return NEWSTRINGS

This is the basic layout of the file, just call it something like "strings_yourmodname.lua" and put it directly into the scripts. In modmain you'll want to add these lines:

local function TableMerge(t1, t2)    for k,v in pairs(t2) do        if type(v) == "table" then            if type(t1[k] or false) == "table" then                TableMerge(t1[k] or {}, t2[k] or {})            else                t1[k] = v            end        else            t1[k] = v        end    end    return t1endGLOBAL.STRINGS = TableMerge(GLOBAL.STRINGS, GLOBAL.require("strings_yourmodname"))

 

Now you can add all the prefabs you create in all caps into the list of NAMES and DESCRIPTION for each character if you want. Just always think about adding commas of the end of the line when adding elements to tables

 

EDIT: For a small mod it's also enough to do something like

local STRINGS = GLOBAL.STRINGSSTRINGS.NAMES.RAT = "Clockwork Vermin"STRINGS.CHARACTERS.DESCRIPTION.GENERIC = "Look, it's a rat!"

EDIT: And about that hitbox. It's a currently missing/buggy feature of the exporter. We shouldn't see anything change there until it's properly ported to Mac and Linux. So right now we'll have to deal with tiny boxes  ; )

Link to comment
Share on other sites

For a bigger mod it's probably more convenient to create a file for all your strings instead of overwriting every string directly in the prefab.

Oookay, so basically what this does is that uh.. Names and descriptions of my prefabs can be changed in this one file? I'm having a hard time understanding the concept of "strings" since I'm new to coding.

So after I've added these do I still need the lines inst:AddComponent("inspectable") in all of my different prefab?

And I should delete this one because my new string-file will define the names etc, yes? inst.components.inspectable.nameoverride = "Clockwork Pawn"

Shame about the hitbox, hope it get fixable soon. Thanks I'll try all this and come back :-)

EDIT:

yBp38tS.png

You are a beautiful wizard

EDIT: Dunno why I changed the "Vermin" part of the code, I kinda liked that name better

Link to comment
Share on other sites

One of the most important (in my opinion the most important) things in lua is are tables. Find a good text somewhere which explains how tables work (this should be a good starting point) Because all strings are stored in a table called STRINGS. This table has a certain structure so that when you add the "inspectable" component (yes you still need it) everything get's hooked up properly. And I basically rebuilt that structure in that file so it all fits nicely.

 

And string is a specofic data-type, which is also important to understand when coding. In Lua there are the following data-types

-nil

This is basically the type that means exactly "This is nothing", it's quite useful you'll find out  ; )

-number

Self-explanatory, they consist of 0-9 and a single dot

-boolean

Either true or false

-string

Always denoted by the " around it. Basically this is just text.

-table

Anything with the { } is a table. You can store any types of data in a table (also other tables)

-function

Well, a function is everything which you can call by putting brackets behind it like AddComponent for example

 

I hope that wasn't overkill for you. But you basically already came in contact with each of those in one way or another and understanding them to a certain degree is important, but that should work out  ; )

Link to comment
Share on other sites

I hope that wasn't overkill for you. But you basically already came in contact with each of those in one way or another and understanding them to a certain degree is important, but that should work out  ; )

Hahaha, well, I'll have to think about all of this for a while. I'm sure the more I expose myself to coding the more I'll get the hang of it. Hopefully I'll be able to make my own tables soon enough.

For now though I'm still a little stuck at simple things~ Embarrassingly enough I already got stuck with the strings_testmod file we made.

How do I use this part of the code where I make the quotes uniqe?
               WILLOW = {        },        WOLFGANG = {        },        WOODIE = {        },        WICKERBOTTOM = {        },        WENDY = {        },        WX78 = {        },        WAXWELL = {        },

Something like this?

        WENDY = { RAT = "Disdurbing"        },

Or

WILLOW = { DESCRIBE RAT = "Clunky"        },

I can't get any combination to work... sigh x)

And how would I go about adding more prefab descriptions in the future?

EDIT: Nevermind! I got it working with

WENDY = { = { DESCRIBE =             {RAT = "Every pawn is a potential queen, will you live up to it?"}         },

f1yVxzi.png

Link to comment
Share on other sites

You can basically copy the contents of GENERIC (which is what you did, so yeah...)

 

And what do you mean with "And how would I go about adding more prefab descriptions in the future?"? If I understand you correctly you mean: How do you add the strings for new prefabs? In that case you'll want to do modify the DESCRIBE table like this

DESCRIBE = {    RAT = "Look, it's a rat!",    NEWPREFAB = "That's new....",},

So you'll really just add a new line with the key, that's the thing before the =, being the name of the new thing in all caps and the value, after the =, being the new quote and then finish it off with a comma

Same way you'll update the NAMES table.

Link to comment
Share on other sites

WoW Maaan! It is a very,rarely good idea and of course creative thread.

I can not find words to can provide enough attributives,just awesome clever!

There is no way to do not say thanks for this thread!

SMTMS

Heheh, thanks! :)

 

In that case you'll want to do modify the DESCRIBE table like this

Ooh right, yeah I just forgot to mention that when I got it working I kinda also figured out that's how it would be done, thanks though :D

I always feel so smart figuring these basic things out pfaha.

----~*~~*~----

So anyway moving on, right now I'm working on an item prefab, the tail for the rat to drop. I've been looking around files and it seems very easy to manage. The only thing that worries me are the TEX converter tools. It seems very complicated and I remember it being a real pain to get the rat itself working with spriter and all that. Looking at the hand-slot tutorial is slightly helping, but I would probably end up missing one detail.

So far I got this prefab coding done and the image

local assets={	Asset("ANIM", "anim/cable.zip"),}local function fn(Sim)	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()        MakeInventoryPhysics(inst)        inst.AnimState:SetBank("cable")    inst.AnimState:SetBuild("cable")    inst.AnimState:PlayAnimation("idle")        inst:AddComponent("stackable")	inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM    inst:AddComponent("inspectable")        inst:AddComponent("inventoryitem")	    return instendreturn Prefab( "common/inventory/cable", fn, assets, prefabs)

WlcfFzg.png

Anyone that can help me show how to mix these together properly with naming the folders and all? So that they convert into TEX files properly~ I know most about how to handle the spriter animation and how to name the things inside properly, so that part is okay.

Link to comment
Share on other sites

 

Actually, adding the artwork for the item should also be done in Spriter, so you don't need any tools but the Mod Tools. And once you get the hang of it you'll finish the conversion for a single prefab in mere minutes.

The prefab looks fine for me, assuming that "cable.zip" actually exists of course  ; P

What you'll want to add though is the inventoryimage. Load the assets (image and atlas) and use

inst.components.inventoryitem.atlasname = "images/inventoryimages/cable.xml"inst.components.inventoryitem.imagename = "cable"

And the tex and xml are created by the Mod Tools if you just put your png into the right place.

Link to comment
Share on other sites

What you'll want to add though is the inventoryimage. Load the assets (image and atlas) and use

inst.components.inventoryitem.atlasname = "images/inventoryimages/cable.xml"inst.components.inventoryitem.imagename = "cable"

And the tex and xml are created by the Mod Tools if you just put your png into the right place.

Ah okay :) So do I put the inventory image in /mymod/images/inventoryimages then? And where should I put the .scml files?

I just took a peek at the pickleit mod too and found this

Asset("ATLAS", "images/inventoryimages/cabbage_cooked.xml"),Asset("IMAGE", "images/inventoryimages/cabbage_cooked.tex"),

The code is slightly different? :p

Link to comment
Share on other sites

 

Yes, that's where you'll need to put the png.

Well, that sliver of code you posted is what I abbreviated with "load the assets"  xD

The thing I posted needs to be beneath

inst:AddComponent("inventoryitem")

And concerning the animation everything works the same as for the rat. Put it in "exported/anim/cable/" for example

Link to comment
Share on other sites

So everything seemed to be working, but as I tried to spawn a couple of cables in the game said no such thing existed. Looking into modmain.lua I remembered I had to add "cable", into the little prefabfiles list.

Starting the game up though this error came up :v


KmoGJtw.png


modmain.lua
local function TableMerge(t1, t2)    for k,v in pairs(t2) do        if type(v) == "table" then            if type(t1[k] or false) == "table" then                TableMerge(t1[k] or {}, t2[k] or {})            else                t1[k] = v            end        else            t1[k] = v        end    end    return t1end GLOBAL.STRINGS = TableMerge(GLOBAL.STRINGS, GLOBAL.require("strings_testmod"))--[NEW] This is how we tell the game we've created a new prefab.PrefabFiles = {	--[NEW] This is the name of our prefab file in scripts/prefabs	"rat",    "cable",}--This function spawns the creature at the player's position.function SpawnCreature(player)		--Get the player's current position.	local x, y, z = player.Transform:GetWorldPosition()	--[NEW] Spawn our new creature at the world origin.	local creature = GLOBAL.SpawnPrefab("rat")	--Move the creature to the player's position.	creature.Transform:SetPosition( x, y, z )	end--Tell the engine to run the function "SpawnCreature" as soon as the player spawns in the world.AddSimPostInit(SpawnCreature)

cable.lua

local assets={	Asset("ANIM", "anim/cable.zip"),}local function fn(Sim)	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()        MakeInventoryPhysics(inst)        inst.AnimState:SetBank("cable")    inst.AnimState:SetBuild("cable")    inst.AnimState:PlayAnimation("idle")        inst:AddComponent("stackable")	inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM    inst:AddComponent("inspectable")        inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/cable.xml"    inst.components.inventoryitem.imagename = "cable"	    return instendreturn Prefab( "common/inventory/cable", fn, assets, prefabs) 

Link to comment
Share on other sites

So everything seemed to be working, but as I tried to spawn a couple of cables in the game said no such thing existed. Looking into modmain.lua I remembered I had to add "cable", into the little prefabfiles list.

Starting the game up though this error came up :v

KmoGJtw.png

Is there a prefabs table? Make sure something like this exists:

 

local prefabs = {

    "cable",

}

 

Edit: Or, if you don't want drops, just do what Malacath suggested.

Link to comment
Share on other sites

 

...those little things I always missed. Look at the last line

return Prefab( "common/inventory/cable", fn, assets, prefabs)

Here you're passing over the variable prefabs which was never declared. You don't need it so you can delete it from there, not the line, just the prefabs, like so

return Prefab( "common/inventory/cable", fn, assets)
Link to comment
Share on other sites

Great! All is working :-)

There's no image showing up in the inventory for the cables, does that mean I did something wrong or have we just not covered that part yet? Also, hovering over the item in the inventory doesn't say examine or anything, where do I set in such aesthetics?

EDIT: Hm, the cables are very massive once laying on the ground, is there a way to resize them like I did with the rat?

inst.AnimState:SetBank("cable")inst.AnimState:SetBuild("cable")inst.AnimState:PlayAnimation("idle")anim:SetScale( .5, .5 )

This gives me an "variable 'anim' not declared" error, so I assume I need to change the scale line to something simular to inst.AnimState or simply declare an 'anim' variable? What ever that means .-.

Link to comment
Share on other sites

Great! All is working :-)

There's no image showing up in the inventory for the cables, does that mean I did something wrong or have we just not covered that part yet? Also, hovering over the item in the inventory doesn't say examine or anything, where do I set in such aesthetics?

EDIT: Hm, the cables are very massive once laying on the ground, is there a way to resize them like I did with the rat?

inst.AnimState:SetBank("cable")inst.AnimState:SetBuild("cable")inst.AnimState:PlayAnimation("idle")anim:SetScale( .5, .5 )

This gives me an "variable 'anim' not declared" error, so I assume I need to change the scale line to something simular to inst.AnimState or simply declare an 'anim' variable? What ever that means .-.

Because you didn't specify what 'anim' is, like in the rat prefab. :razz:

Link to comment
Share on other sites

So, aha, uh, how did I specify it? :razz:

Oh, is it an local anim = inst.entity:AddAnimState() I need to add?

Yup. By putting 'local anim = inst.entity:AddAnimState(), you're declaring 'anim' as local variable, which means that it can only be called from within that prefab/class.

Link to comment
Share on other sites

Yup. By putting 'local anim = inst.entity:AddAnimState(), you're declaring 'anim' as local variable, which means that it can only be called from within that prefab/class.

This is superb, I feel like I'm getting the hang of this now :)

So you didn't know anything about the mouseover text not showing up or the icon for it neither at the inventory?

Link to comment
Share on other sites

Probably yeah! :-) I got a handful of quotes in mind already though. Unless by "quote" you mean some coding thing I haven't heard of and not character quotes? Also what does strings do again? .__.

 

 

Yeah, I meant character quotes.

 

And strings are things like crafting descriptions, the stuff that appears during wordgen saying things like Generating pathos, or Herding Wilsons beard, and other, writing related things.

Link to comment
Share on other sites

Yeah, I meant character quotes.

 

And strings are things like crafting descriptions, the stuff that appears during wordgen saying things like Generating pathos, or Herding Wilsons beard, and other, writing related things.

Okay, awesome, I'm having trouble for what Wickerbottom should say regarding the rats and their tails actually, I set to to "Vermin pests!" for the rats but mmmhmm, it sounds rather weird. Considering they're not really Vermin, just robots.

 

Hmm. Do you have an images/ folder within your mod? What are its contents?

Yeah here http://i.imgur.com/Xc3wKwl.png

I just remembered that the tutorial mod mentioned something about 64x64, could that be it?

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...