dont flame if this is explained anywhere, i didnt find it and just stumbled upon this engine a few days ago ;)
I have a couple of scenarios where item a combined with item b will result in items c [d, e …]. as i find it rather complicated to do this all in the item functions, i had the idea to do this in a global event function and used the UnhandledEvent(LocationType type, CursorMode mode, InventoryItem *clickedItem)
approach.
My idea is to basically do the following:
• define a something (struct?) holding the following information:
- item1
- item2
- an array of resulting items
- some special flags defining prerequisites met
- optional pointer to a fuction called if item has been succesfully created
• define another something consisting of
- an array of above somethings
- a function that lets me define relations
- a function that gets called by the event and that checks
- if a relation between both items already definded?
- if yes, are the prerequisits met?
- if yes, remove items from inventory, create new ones
- probably call function
is this possible with the scripting language or should i do another approach?
What you are suggesting is certainly possible. I personally would still do it the simple way with seperate functions for each combination (and each with a "//egg + nest = egg in nest" kind of notation for easy script searching).
But I guess if you have a huge number of possible combinations and outcomes, like 50 or 100 or more then building an array which works like a map or flowchart to handle it all is a smart way to go.
As for the actual coding suggestions I will let someone else tackle that daunting task ;)
Quote from: Mandle on Sun 21/12/2014 01:04:21But I guess if you have a huge number of possible combinations and outcomes, like 50 or 100 or more then building an array which works like a map or flowchart to handle it all is a smart way to go.
The biggest part of the game will be about combinations, i think ~50 is a good guess. BTW this is such a basic functionallity, it probalbly should be part of he engine itself. :)â€"?
Does this outline requires that i have to wait for managed structs (http://www.adventuregamestudio.co.uk/forums/index.php?topic=51050.0) to become available?
from "new" in the manual:
QuoteCurrently dynamic arrays are supported as global and local variables, but you can't put one inside a struct. Also, at present you can create arrays of basic types (int, char, etc) and of built-in types (String, Character, etc) but not of custom structs.
is this going to be changed … soon?
Quote from: .rhavin on Mon 22/12/2014 11:13:58from "new" in the manual:
QuoteCurrently dynamic arrays are supported as global and local variables, but you can't put one inside a struct. Also, at present you can create arrays of basic types (int, char, etc) and of built-in types (String, Character, etc) but not of custom structs.
is this going to be changed … soon?
This is one of the primary tasks we set for the 3.4.0 release, and I hope we'll accomplish it. I can't tell how fast though.
This task also implies nested managed structs (managed object references inside other managed structs).