Jump to content

Recommended Posts

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:

1YgkbRy.jpg

 

Help would be appreciated :P

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

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

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...