Array Questions

0 favourites
  • 14 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • So i am on a part of crafting items. I would like to create a system to where whenever you are in the crafting menu you will be allowed to drag materials in the window to see if it yield any craftable items. Such as this Stone and Stone to the little window. and the result would be a sharp stone

    Now i know from a variable stand-point that all it require is just if you have 2 or more stone you get a sharp stone but what if i got another 2 thousand more worth of craft-able other items. So I figure perhaps i can use An array system that would checks recipes of craft-able items.

    From my current limited knowledge I do not know if there a string to check array by the rows only such as this if stone and Another stone on the same of the array at Y=0 to show what it can produce .

    so for instance if i pick a stone and a stick in the window it should not yeild anything since at the Y 0 line stone and stick does not appear on the same line.

    And I would like to know if it possible for me to create a system where i can make the game to check recipes per line rather then per coors? How would one tell contruct two to do that.

  • Just to let you know, I'm working on an example for you.

    By the way, it's in XML, I think that's more suiting for a crafting system than an Array.

  • Here you go:

    Download .capx

    Important:

    This is a very rough and unfinished version, not very backend-friendly.

    It is not commented, so it probably is quite confusing.

    I don't have the time to comment it yet, so I will add that later.

    You will also have to understand XML to understand how the program works.

    You won't need it though to add new recipes, since XML is easy to edit.

    There is also one quite big issue:

    Recipes with more than one ingredient of the same kind (like Sharp Stone, 2xStone) will be crafted with one ingredient only and will cause other recipes with the same ingredient to stop working correctly.

    I'll probably address this in the future, if you can't fix it yourself.

    It is possible, but quite tedious.

    This is my first use of XML in a project, so keep in mind that there might be better solutions than the one I used.

    You may want to bump this thread if you think you need more help.

  • hmmm After looking at it wouldnt it make sense to add in something like a counting system. such as if one text of stone get placed in the box add one to a counter. and if another UID get entered then add one and have the crafting system use if 2 or more are place make 1 sharpstone.

    Cause atm you are right about the bug but that because you dont have anything define how many of each but rather just text of one.

  • Yeah the thing is, the whole system uses XML, so I can't just simply use a variable since I would have to combine the variable with the XML which would be quite tedious.

    What I can do though, is add a dictionary that counts the amount of every text object and combine that with the rest.

    Though I still think that my solution isn't very effective, but it was the only thing I could come up with.

  • Well i did find something useful is that What if we used a an id system for each item creation and then reverse check it in a looping matter cause this one website that explain the XML was very helpful and it check to see if you can use expression.

    http://www.freeformatter.com/xpath-tester.html

    it showed some really neat things. So im thinking what if we created a whole new dictionary to store just the id of each creation and have it to check the Item count with the current picked to where if we have two stone dictionary a counted for and two item it would know to use them both. Would we use a loop here something like Loop 1-(count(//Item) Which in our case would be 6.

    So therefore we would have an id of each created item with the ID number to use so that we could techspeaking loop check them or something like that. I know its here somewhere. But im super confuse to where to place each of the loops. and Where to check the count of <i>

    CAuse if we can get it to know two stone and there is a recipe for it then create it. What do you think ? and for anyone else who is pro at xml files would help us understand it better and how to event it correctly.

  • Actually, I'm quite familiar with XML now, so most of the XML-related stuff shouldn't be much of a problem.

    The issue is:

    We can't use a dictionary to store the items the are dropped on the input.

    Why?

    Because dictionaries don't allow multiple keys with the same name.

    So what we need is a way to differentiate between multiple instances of the same object or to merge multiple instances into one dictionary entry.

    If we got this to work, then there wouldn't be any problem whatsoever.

    Actually, I have difficulties understanding the ID system you tried to explain.

    What do you mean by ID? Based on what pattern do you want to generate it?

    What do you mean by Creation? Do you mean the output of a crafting process? Do you want to backtrack after crafting something?

    _______________________________

    [quote:1hbgiadr]check the Item count with the current picked to where if we have two stone dictionary a counted for and two item it would know to use them both. Would we use a loop here something like Loop 1-(count(//Item)

    If you explained this to me a bit more detailed, we could surely come to a solution.

    (As I said, the XML parsing shouldn't be much of a problem)

    _______________________________

    I think, I found a solution, just need to test it.

    This is what I think of:

    When adding the items on the crafting table ("Input") to the dictionary, we could simply check whether a same key already exists.

    If it does, we add 1 to its value, if it doesn't, we create a new one.

    I'll post a new reply if it works. It should.

  • The id thing is if you look at the xml examples that the website show it shows actor id=2 or 3 or 1. This is an id attribute which is something ive seen in multiple modern day games have.

    So by using the Id attribute we could tech use it to our advantage to coordinate which item we want to check and which to loop through rather then using <i>. Does this explain better?

  • Let it be clear, i am not against XML (i just understand zip of it yet)

    This is just another approach.

    1 Array to hold the rules (an easy way) and for the unlocking of newly found items. I suppose you need to trow that one in the local store at 1 point.

    1 Array for easy (outside the boundary of an event) calculations.

    https://www.dropbox.com/s/bx72b5oqprveb ... .capx?dl=0

  • Got it to work now.

    Download .capx

    (The only thing that isn't perfect yet, is the way it handles recipes with the same list of ingredients as another recipe. It will produce the first one in the XML. If you need this to work too, just gimme a shout.)

    Concerning 99Instances2Go 's version:

    I didn't look at the .capx, but Arrays are (probably?) more complicated to setup, but easier to handle than XML's.

    It's probably more sensible to go with the Arrays. 99Instances2Go does quality work, I have experiences that myself already, haha.

  • So in other word if sharp stone require two and another recipe require two stone only the first will be used?

    Heres an idea what if say we did have two stone in there but instead of automatically straight to the output but rather list the outcome of certain recipes and select the recipes. Now I dont think ill never use this idea but What if you accidental place two stone there and realized that you dont need a sharpstone again.

    I was thinking of something like what if you wanted to have two recipes one is for sharpstone and the other is flint.

    And how would I use this if i need it to be a tool use wise such as this if want to make Twine from a plant and i need to use sharp stone but i dont want to remove sharp stone

    I can only think of one way is by adding results to clone a tool again to fake that you used it.

    .....@99Instances2Go

    Im lost to how you came up with a combine rule

    AT first i thought you use frames and then added the two frame number together to get the X

    When my calculation didnt turn up.....I then thought what if you use two frame to find the X,Y value

    That didnt turn up correctly.

    Why did you use for loop to find sum and I dont think this will quite work because this is a suvivial style game and crafting need to be used in different ways. Such as do you have the tool for it. Do you have the require material and what kind of yield will it give.

    But this method would only work if you just want to based a game around adding a god elements to the world. then this would be it but as far as using items and such this would pretty much be a debug nightmare. XMl is alot more simplier.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:pixc7ewh]instead of automatically straight to the output but rather list the outcome of certain recipes and select the recipes.

    Yep, that was my idea too.

    Again, this will take some time.

    And since I'm on holiday from tomorrow until 29th, I probably won't finish this until then.

    But it definitely is possible.

    Please tell me if you're gonna stick with the solution of 99Instances2Go ,because if you do, I can keep the XML crafting thing as a personal challenge and don't have to hurry.

  • Best keep crafting. And i find your XML adventures interesting.

  • well theres no rush no deadline But would like to see these Xml to come to fruit so that other ppl like us can learn different things that contruct is cappable of.

    Have a good christmas to you guys. Cheers

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)