lxFirebal69xl Posted March 23, 2015 Share Posted March 23, 2015 I've recently been battling this one and I think it would be awesome to do and then put it out there for everyone to use, I mean, a point system is common in a lot of games, and while I still haven't been able to do it quite like I want it to be, I do have some ideas as to how I want it to look. It should work in a simple way, you click the object and the number of points show up before disapearing, then showing a total of how many points you have at the end of the level. Example: Help would be appreciated Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 23, 2015 Share Posted March 23, 2015 what's the problem? Script.points=1 --int "points" function Script:Use() points=points+self.points end Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 what's the problem? Script.points=1 --int "points" function Script:Use() points=points+self.points end The problem is that I want it to be across all levels I figured out this much myself.... XD Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 23, 2015 Share Posted March 23, 2015 I think global values won't be deleted when you change the level as they are not tied to any entity in the world. So what I wrote should work across levels. If you want to store points between game launches, then you can write it to a file. Do you want that? Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 I think global values won't be deleted when you change the level as they are not tied to any entity in the world. So what I wrote should work across levels. If you want to store points between game launches, then you can write it to a file. Do you want that? Yeah, pretty much... Quote Link to comment Share on other sites More sharing options...
Rick Posted March 23, 2015 Share Posted March 23, 2015 You can make your variables part of App and you'll be good and they will have some "namespace" to them and not just floating globals. App.runes= 0 App.boneCharms = 0 -- etc... SpecialItem.lua Script.name = "" --string "Special Item Name" function Script:Use() App[self.name] = App[self.name] + 1 end Then give your special name setting the same name as your App variabels like "runes", "boneCharms" on the entity/model they are attached to. Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 23, 2015 Share Posted March 23, 2015 Yes, or with the same result you can make a global table like this: stats={} stats.points=0 For files you use FileSystem and Source classes. It's simple and convenient as everything in Leadwerks. Example that you need is already in documentation: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/filesystem/filesystemwritefile-r650 Quote Link to comment Share on other sites More sharing options...
Rick Posted March 23, 2015 Share Posted March 23, 2015 @Fire Side note: if you start using file system stuff I don't believe the game will work in the LE player as it's sandbox mode and i/o doesn't work in sandbox mode. Just something to consider if you wish to use the player for demo reasons as well. You'll want to create a means to skip file io when ran from it. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 Thank you both for the answers, much appreciated! Quote Link to comment Share on other sites More sharing options...
Josh Posted March 23, 2015 Share Posted March 23, 2015 I had a similar idea recently from playing all your guys' games. Like, having a standard display at the end of the game that shows secrets found, enemies killed, etc. Sounds fun and it adds to replayability. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 I had a similar idea recently from playing all your guys' games. Like, having a standard display at the end of the game that shows secrets found, enemies killed, etc. Sounds fun and it adds to replayability. Josh knows what's up! This is exactly what we need! Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 23, 2015 Share Posted March 23, 2015 One more thing. If you want to save a list of different points into a file you can make it like this: first points=12 second points=25 another points=72 And then when you read the files to get points you can find equal sign and split string by it. Use default Lua functions like this one for that: http://www.lua.org/manual/5.3/manual.html#pdf-string.sub It will be like this: you open a file, read a first string, get this value: "first points=12". Then you loop through all symbols in the string looking for "=" and take everything after it. And it will be your first points value. I do it like this for stats of weapons stored in a file. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 Allright, so I think I got everything set up. Now, how do I make so that either when the player finishes a level or picks an item up, a texture is drawn with text on top of it saying (example) "Notes found 2/4" Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 23, 2015 Author Share Posted March 23, 2015 One more thing. If you want to save a list of different points into a file you can make it like this: first points=12 second points=25 another points=72 And then when you read the files to get points you can find equal sign and split string by it. Use default Lua functions like this one for that: http://www.lua.org/manual/5.3/manual.html#pdf-string.sub It will be like this: you open a file, read a first string, get this value: "first points=12". Then you loop through all symbols in the string looking for "=" and take everything after it. And it will be your first points value. I do it like this for stats of weapons stored in a file. Thanks for the in-depth look at the files and how the work Quote Link to comment Share on other sites More sharing options...
dennis Posted March 25, 2015 Share Posted March 25, 2015 You can create a database for all those variables. Sqlite 3 for example.. Or if you are working in c++ you can use mssql or something like that Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted March 25, 2015 Author Share Posted March 25, 2015 You can create a database for all those variables. Sqlite 3 for example.. Or if you are working in c++ you can use mssql or something like that You saying that gets me nowhere because it's the same if someone spoke chinese to me I am not working in c++ though. Quote Link to comment Share on other sites More sharing options...
dennis Posted March 25, 2015 Share Posted March 25, 2015 Hmm, back with LE2 i used sqlite database with lua. When you pickup a note, artifact or some other stuff you write it away in a database. Sqlite3 is a flat file database... You add a increment variable for example: Notes = 0 Everytime you pickup a note it will increment +1. A note has a example value of 100 pts. Every note which sits there in database Has to be retrieved so you get the count of the notes. Your script sees 10 * a value of 100 and that's your score. http://lua.sqlite.org/index.cgi/index Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.