Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
After much hassle I have managed to create and save an array in CopperCube. It saves & loads back up fine also: http://lasttrump.net/gamedev.html I wanted to use an array as its like a table of data that can be queried and able to save many variables easily and interconnected with multiple item characteristics per inventory slot. I am posting here for free - hope you like. Also see a copy of my game to date showing how it works in practice. I have it all in simple array style in one big string separated by commas. Each inventory slot has 11 different sub variables so that the whole list always has a factor of 11 elements in it. The inventory download has the spreadsheet showing each element for each inventory slot - you can use for yourself in your game if you like. To save use: var data = invMe.toString(); ccbWriteFileContent('save.dat', data); or save as normal method also as a single varaible 'invMe' if you like. To reload: data = ccbReadFileContent('save.dat'); var load = data.split(","); var invMe = load; Enjoy. |
||||
|
This is actually a very reliable system. Could you make a tutorial for inexperienced programmers? |
||||
|
can you actually use images with this for use of inventory so its not so plain? |
||||
|
Re-download to get it fixed so that the sounds and images works now - just a referencing issue. Alternatively just put the CC exe file inside another folder from where its located and should work fine then also. A video on this...mmm if I get enough requests could do that maybe... |
||||
|
yes i would like a tutorial also on this! |
||||
|
I would 2 |
||||
|
Ok, I will do a video on it then in the next 3-4 days... |
||||
|
Thank you very much. |
||||
|
ok - see attached video link: https://youtu.be/u2kNmFx05uE |
||||
|
Awesome! Thank you for this. Was looking to make a inventory system. How hard would it be to make picking up an item by pressing an action key, like "e" instead of the left mouse button (or single or double pressing on it if the game is for a tablet or phone)? How would we add text to it, like "Water" or "Pick up water"? Thanks. Mike |
||||
|
wrote: Awesome! Thank you for this. Was looking to make a inventory system. How hard would it be to make picking up an item by pressing an action key, like "e" instead of the left mouse button (or single or double pressing on it if the game is for a tablet or phone)? How would we add text to it, like "Water" or "Pick up water"? Thanks. Mike you could create a new variable (eg 'item') to hold the name of the object you moved the mouse over (on highlight). You could then use that node name like 'water1' for example with if 'E" is pressed check is that 'item' is not null then do the same stuff as I have on click... so yes should work ok. I haven't done anything for tablets/phones so unsure about that... |
||||
|
Any Inventory needs goodies distibuted in a terrain. Thats what this script does. enjoy /* Operation Manna: distribute game goodies in a raster over the playfield by Cloning hidden nodes, goodies dropped from the sky (GoodyPosZ) to the ground: Collision -> AffectedByGravity Collision will automatically push it to the ground with adaptation of x,y coords No need to keep track of goodies as they autodestruct by attached timer event and JS-code JS-code: ccbRemoveSceneNode( ccbGetSceneNodeFromName("Gun-0") ); 3dnoob's copi2 maze building derivative by Douwe Dabbe */ |
||||
|
part 2 (having difficulty posting ascii text) /* <action jsname="action_makeManna" description="Operation Manna: Distribute Game Goodies"> <property name="worldXmin" type="int" default="-1000" description="Distribution Limit X min" /> <property name="worldXmax" type="int" default="1000" description="Distribution Limit X max" /> <property name="worldYmin" type="int" default="-1000" description="Distribution Limit Y min" /> <property name="worldYmax" type="int" default="1000" description="Distribution Limit Y max" /> <property name="MannaData" type="string" default="G---D---L---G---" description="- = none, stringlength=power of 2"/> <property name="MannaHeight" type="int" default="1000" description="falls from height" /> </action> */ action_makeManna = function() { // Empty }; /* more substantial test data: var MannaData ="----D--L--L--G--G-L--G-------L---L-----GG-L--------L-----L-----L-------L-----GG---L---D----L-----G-----DD---------L--D--L-----L----L--------G------L-----L---L------L---L-LDDLD--L-----L------------L------G-G--G-----G---------GL-----D----G--------L------------DL---------G-----G-------DL---------L-------D--------LG------G-G-G-G---------L-DG-----G----------L----L---L---LLLL-------GDGD-----GG-GGG-G----"; */ action_makeManna.prototype.execute = function(currentNode) { // transfer parameters for performance sake var areaXmin = this.worldXmin; var areaXmax = this.worldXmax; var areaYmin = this.worldYmin; var areaYmax = this.worldYmax; var MannaString = this.MannaData; var GoodyPosZ = this.MannaHeight; // calc. goody coord. factors var Len = MannaString.length; var maxH = maxV = Math.round(Math.sqrt(Len)); var stepX = Math.round((Math.abs(areaXmax) + Math.abs(areaXmin))/maxH); var stepY = Math.round((Math.abs(areaYmax) + Math.abs(areaYmin))/maxV); var offsetX = stepX/2; var offsetY = stepY/2; print("Len = "+Len+" maxH = "+maxH+" stepX = "+stepX+" offsetY = "+offsetY); // Manna will fall from the sky, var Goody = "-"; var GoodyPosX = 0; var GoodyPosY = 0; var sourceNode; var newscenenode; for ( street=0; street<maxV; street++ ) { // calc GoodyPos at the next street on the vertical GoodyPosY = Math.round(areaYmin+offsetY+(street*stepY)); for ( house=0; house<maxH; house++ ) { Goody =MannaString[(street*maxH)+house]; // print("Goody = "+Goody); // calc GoodyPos at the next house on the horizontal GoodyPosX = Math.round(areaXmin+offsetX+(house*stepX)); switch(Goody) { case 'G': // Create Gun print("Goodie: "+Goody); sourceNode = ccbGetSceneNodeFromName("Gun-0"); newscenenode = ccbCloneSceneNode(sourceNode); break; case 'D': // Create Dollars print("Goodie: "+Goody); sourceNode = ccbGetSceneNodeFromName("Dollar-0"); newscenenode = ccbCloneSceneNode(sourceNode); break; case 'L': // Create Liquor print("Goodie: "+Goody); sourceNode = ccbGetSceneNodeFromName("Liquor-0"); newscenenode = ccbCloneSceneNode(sourceNode); break; case '-': // pass empty print("Goodie: "+Goody); break; default: // unknown item print("Goodie: "+Goody); break; } ccbSetSceneNodeProperty(newscenenode, "Visible", true); ccbSetSceneNodeProperty(newscenenode, "Position", GoodyPosY, GoodyPosZ, GoodyPosX); } // end house } // end street } // end action |
||||
|
wow - that is some amount of work. I will put in into a jc action file and try it out.... thanks for sharing! |
||||
|
Can someone help me set this up to repeat the arrays placement of objects. Like and infinite grid? Island, ocean, island, ocean. So the same geometry repeats itself infinitely. |
|