About Crafting System (newbie)

Hello Guys!

I'm checking the forums for 3 days but I couldn't see something about what I need to do. Because of that I opened this topic.

So I'm trying to prepare simple survivor game. But There is a problem so Player needs to craft lots of items unfortunately. I guess I can use 2 option, Create Object and Get Object.

If I can prepare 2 lists. One of them just creatable objects(creat.xls) and other details(att.xls) of the object. creat.xls has the list of the objects and how many resources they needs. att.xls has the attiributes of the objects. I tought if I can prepare lists like that maybe it will be much more easier to check which resources player has and able to create.

I gave to extensions for example. Is it possible to do something like that? or which way I need to follow?

Thank you so much for help.


I've made a crafting system before, and I think you've got a good idea.

As far as the attributes for crafted items, it's probably easiest to create one of each item and store them outside player space (outside any room), and then clone those objects when the player creates one.

I've created a simple crafting system before, as an experiment, and would be happy to share the code if it's useful to you.


Thank you for your answer mrangel. Would be really happy if you can share. At least I can understand little bit more about crafting and coding.

I was thinking about cloning objects too but after thinking how many lines of code I need to write for checking all of the resources etc. using this kind of db will be much more easier I guess and with this kind of db I can prepare crafting menu easily. If the player has all of resources and tools then in the menu, items can be active or visible. It will be much more easy for player too. I'm not familiar with coding so I'm also not sure Quest supporting this kind of db or not.


(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


I've never done an advanced design for crafting (it would be helpful for us/mrangel for you to describe/explain what you want with your crafting system and how you want it done, and how it works for the player, as much as you can, as there's lots of designs and complexity/scale, so we'll/mrangel need to know what exactly you want for your crafting system)

so, since I've never done this before, in just thinking about it, I'd imagine for the most complex/advanced crafting system with lots of data/stuff usage, you'd want:

(quest is extremely powerful, it can pretty much do anything programming/code-wise/game-design-wise)

  1. base stuff (Objects, Attributes, Object Types, and/or etc) that you can clone
  2. combining/concatenating lists' items
  3. advanced data structures (like trees)
  4. recursion

but, there might be better design methods for doing an advanced/complex crafting system, as I've never tried one myself yet

though, I'll let mrangel help you with this stuff, as I've never tried doing this stuff myself and am still not that great at it (data structures and recursion)

(I'll be lurking though, to learn myself, and if I can offer any help, I will)


morrowind's (hadn't played oblivion or skyrim) alchemy (crafting/mixing) and/or spell-making (crafting/mixing) systems are pretty advanced/complex:

https://en.uesp.net/wiki/Morrowind:Alchemy
https://en.uesp.net/wiki/Morrowind:Ingredients

https://en.uesp.net/wiki/Morrowind:Spellmakers (has a little bit about making custom spells)
https://en.uesp.net/wiki/Morrowind:Magic
https://en.uesp.net/wiki/Morrowind:Spells
https://en.uesp.net/wiki/Morrowind:Spell_Effects

Thank you for your answer hegemonkhan. Firstly yes It's really complex system I know that. :D So I'm preparing tropical island survival game. Player will start with nothing. Player needs to find everything on the island. Because of that there will be some combinations.

For example you can use vine for making stone axe. Or if you can find fishing line you can use that too. Than it will be have different durability. Or you can use dry leaves or dry coconut as tinder. etc. etc. Because of that I need to put different resources and tools. All of them will have different attributes. For the beginning I can do like clone item from different room. But in the future I need to use db or something like that.

Because if I write script for checking all of the resources that player has in the inventory will be difficult. If I need to do some changes later, it will be so easy to change that in DB also.

I'm thinking if I can use DB, I can create a crafting menu. So in this crafting menu player can see what he/she able to create easily.

For example

If player has sharp stone, small wood and vine or fishing line can create stone axe. Script will check the resources in the player's inventory and db after that will show in the command/crafting menu the things that player can create. When player choose a item for create script will check the details(attributes) for that item from other DB and will give item to the player.

In that way I don't need to write script for every possibilities because all of them already in the DB. I know it's looks like I'm a lazy person but I'm also thinking for future improvements like item dryness level like wet wood can not used for camp fire etc. etc.

I hope I explained how I'm thinking.


Objects can store data (Attributes) and actions (Script Attributes / "Verbs"), as well as using Delegates (quest's means of allowing the Object's actions: Script Attributes / "Verbs", to act like Functions: having/doing return values and/or parameters/arguments/inputs), and also they can be created with an Object Type / Type (see below) too, so Objects are the best container structures in quest


you can also create Object Types / Types, which act like user-level classes/groups (example in code below)

// to do so in scripting:

create ("orc1", "orc_type")
create ("orc2", "orc_type")
create ("orc3", "orc_type")

// I don't know if you can through scripting, create/set-up the, Types / Object Types, themselves however

// -----------------------

<object name="orc1">

  <inherit name="orc_type" />

</object>

<object name="orc2">

  <inherit name="orc_type" />

</object>

<object name="orc3">

  <inherit name="orc_type" />

</object>

<type name="orc_type">

  <attr name="strength" type="int">20</attr>
  <attr name="endurance" type="int">20</attr>
  <attr name="dexterity" type="int">20</attr>
  <attr name="agility" type="int">20</attr>
  <attr name="speed" type="int">20</attr>
  <attr name="luck" type="int">20</attr>

</type>

and, you can also create library files:

https://docs.textadventures.co.uk/quest/using_libraries.html

http://textadventures.co.uk/forum/quest/topic/mu7itzjqv0yxrkdwgsbmzg/how-to-make-npc-confront-you-with-chioces#46cdb25b-4767-40a6-8bf4-3cd84e805781 (scroll down to the library section in my big post, though you might want to read the stuff above, and/or my entire post, as I tried to write a guide on understanding working directly with quest's 'asl' game coding)


As far as storing data in an external spreadsheet goes, it's possible.
Reading XLS would probably be a nightmare, but you can probably do CSV with less than a thoiusand lines of code.

I did actually have a spreadsheet containing the ingredient lists. But then I used a macro to convert it into Quest (IASL) code like this to put in the start script:

fish_supper.crafting_recipe = NewDictionary()
dictionary add (fish_supper.crafting_recipe, "fish", 1)
dictionary add (fish_supper.crafting_recipe, "knife", " to gut the fish")
dictionary add (fish_supper.crafting_recipe, "spear", " to hold it with so you don't burn yourself")
dictionary add (fish_supper.crafting_recipe, "campfire", "")

If you were using the desktop version of Quest, editing the attributes directly would probably be easier than writing a script to do it, but they're both valid options.

As far as the crafted items go, creating them as in-game objects will likely be easier because then you can give them any of the features and attributes that an object in Quest normally has. If you were reading their stats in from an external file, then the file would need some way to contain a dozen different types of nested information that might not apply to all objects, and then the script that loads the file would have to account for all those possibilities. Not to mention that your crafted items couldn't have script attributes (because those can't be dynamically created), which means that verbs and a couple of other Quest features aren't practical.

I can look into the reading external files thing if you can describe the layout of your file. Like I said, CSV shouldn't be that hard. But I do think that it would probably be easier to put the information in object attributes unless you've already got a large amount of data in the spreadsheet.

If you want to take a look, here's a linmk to a test game I made when I was playing around with a crafting system. The raw materials just spawn randomly as you walk around (some other stuff behaves oddly, like picking up the crafting manual doesn't work, but it should be a good example of what I mean by a crafting system)


Sorry, I was already replyign before your last message. My own fault for taking so long.

As far as items whose attributes depend on the materials they were crafted from, that's an interesting thought.
The thing is that if you're using a 'flat' database, once you've got more than a few items it rapidly becomes larger, and harder to find the part you want to change if you need to make modifications.

Realistically, you would be looking at a single script that runs on startup and copies the information from a CSV file into the objects' attributes. To me, it seems like editing the attributes for an object would be easier if you go to the object in the editor and all the information is there in a tab; but that may be personal preference.

I can see a couple of ways the data can be structured, depending on more detail of what you're hoping to do. Maybe you could show some excerpts from these databases, examples of how the data will be structured? Then I could give a more helpful explanation of how you'd go about importing it.


Thank you so much for your help guys.

Like you said I will prepare example of DB that I'm talking about and I will write here as soon as possible.


You can try to follow this tutorials : https://www.youtube.com/watch?v=axUHoNlWY2k

Have a nice day.


Hello again.

When I started to make example of DB I realized it's getting much more complicated and also it can be cause lots of errors. I guess it was a not so good idea without advanced coding knowledge. :(

For now I'm planning to do like what you said before. I will continue with cloning and changing attributes from Quest for now. In that time after to learning little bit more about Quest I will consider my first idea again.

I really don't want to steal your time. I will have much more different questions in short time :D


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums