Scripts / Conjured Cash System in Lua

Author
Message
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 6th Feb 2014 23:48
Has anyone else started a cash system for reloaded yet?



I finally got a chance to play with Lua a little bit, so I thought I would try porting the old cash system over to Reloaded. So far it is working out great. I have the cash entity in for picking up cash, and I have the display working. However, I use a constant prompt for the display right now while I am testing, but that will be changed soon when I post the basic scripts up. I am thinking of having the user press a key to display their cash balance rather than cluttering the screen up with it. What do you guys think?



Is it okay to post videos yet or just screen shot?



I made a video showing the cash pickups and display in reloaded.

The video is intended to show the system working in reloaded, and not what a great terrain should look like.

My map is pretty basic at the moment just for testing scripts, so with that said, it should be too bad to post a short video as long as everyone understands it is for showing how the scripts function and not to show off the visual bells and whistles of the new terrain system.

Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 6th Feb 2014 23:56
I'd personally love to see that video

J0linar
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 3rd Feb 2010
Location: Vienna, AT
Posted: 6th Feb 2014 23:59
I think that would be a great addition for R.

It could even path the way for some rpg style elements, like sell food

or armor/ buy.



Let us see that video

http://j0linar.blogspot.co.at/
PM
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 7th Feb 2014 00:05
Well, I noticed someone else has a video posted showing a door and key, so I guess it is ok.

This is not much so far, but it's a start.

Once I get the next script done for buying an item then it will be under way.





J0linar
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 3rd Feb 2010
Location: Vienna, AT
Posted: 7th Feb 2014 00:10
nice one, you might wanna add a optional script for picking up cash by keypress.



Note in some cases like stealth games where the gameplay is different it could be useful.



Looking forward to the buy part.

Great work!

http://j0linar.blogspot.co.at/
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 7th Feb 2014 00:28 Edited at: 7th Feb 2014 00:28
That's awesome man! I got so much to brush up on when it comes to LUA. So you were able to create a variable and add to it?



I should start reading up on LUA

almightyhood
10
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 7th Feb 2014 00:35
cool

have fun stay safe

hood
PM
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 7th Feb 2014 08:29
Any chance of sharing the script?, i'm personally currently hopeless with scripting and going over all the scripts i can to see how it all works

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Feb 2014 13:08
nice job



@AuShadow; if the script doesnt get released u can simply look at the current health script and create one similar for cash (just need to set a variable for money and increase that rather than HP)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 7th Feb 2014 15:01
Ahh didn't even think of that Thanks

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 7th Feb 2014 18:04 Edited at: 7th Feb 2014 18:12
Yeah, this is pretty easy, so you should be able to do it from looking at the stock scripts and the documentation at Lua.org



I am borrowing a section here and a line there from the stock scripts and adding a little stuff from the Lua docs.



Here is an update...





I will release these scripts, when they are finished.

I am brand new to Lua, so I got a little excited when my first attempt to convert one of my old FPI scripts was successful.

xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Location: Rhode Island
Posted: 7th Feb 2014 19:21
Hey CE,



Looks like you're off to a flying start with LUA! Is that the default text and are there any text options yet?



Brian.

If my post seems rude or stupid, don't be offended. It's just a failed attempt at humor.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Feb 2014 19:56 Edited at: 7th Feb 2014 20:20
that's looking really nice now, if only the respawn timers worked then you could make a real shop type effect for ammo and such



how do u use prompt to display a variable alongside some text in LUA?

@xplosys; yes that is the default text from the prompt command and unfortunately it is a very basic output, no way to edit it as of now afaik but i'm sure it'll improve.

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 7th Feb 2014 21:15 Edited at: 7th Feb 2014 21:27
I use the Prompt() function.



The way to prompt a variable's value along with text is by using the .. thingy. (Concatenation)



Prompt("CASH = " .. conjured_cash);



Note that the .. has a space on both sides of it.

This .. thingy converts the numeric value of the variable to a string when it adds it to the text in quotes which is a string. This was the easiest way for me to do it. Maybe there is a better way, but this works great so I will be using this .. thingy a lot.



Of course, the variable name itself is not in quotes.

smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Feb 2014 21:54
ah thanks very much, that's working great

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 7th Feb 2014 22:30 Edited at: 7th Feb 2014 22:33
i have to admit i am keen as anything to get a look in at this script , guarantee i'll be watching this thread for it , nice work. Actually i would like to know if you could possibly share with me both your original script which just had the money pickup and the second one which had the purchasing in it as i am very much interested in seeing the way you have evolved it

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
Emrys
10
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 7th Feb 2014 22:41
Excellent ! Great work



PM
Corno_1
GameGuru Tool Maker
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 7th Feb 2014 23:44 Edited at: 8th Feb 2014 00:36
It seems that my idol is back



I learned with your scripts FPI and now I hope that I can learn Lua from your scripts.



Can you share it with us/me maybe(Even the prototypes).



Also I need your help for a fpi problem, if you can email me I would appreciate it



Corno_1

Make this forum to something a little bit better and release more stuff. So we can push the Request/NoobHelp threads aside.
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 8th Feb 2014 00:07
wow that explanation seems so simple I cant wait to try it out when I get some time.

Spotaru
Game Guru Backer
11
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 8th Feb 2014 04:48
I can't wait to see what you and others come up with. I can script enough to change a hud and such. But some of the things you all came up with in classic was, well.... pardon the pun, Classic !

Looking forward to lua and Reloaded
Jerry Tremble
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 8th Feb 2014 05:19
Very nice! I was thinking about working on complete inventory system which would, of course, include cash flow in either direction. I hadn't gotten around to it yet, but this encourages me to try to tackle it sooner, but of course, when I can find the time! Would be nice to get a peek at it, but maybe this weekend I'll take a look at the health script and maybe I can build from that. Thanks for the inspiration!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Feb 2014 19:31
@aushadow

for picking up money or such just copy (and rename) the health script and replace the "addplayerhealth" line to something like "money = money + 100") and set money as a global variable - put "money = 1000" under "-- Globals (passed-in)"



*
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 8th Feb 2014 21:03 Edited at: 9th Feb 2014 02:46
Quote: "i wont share anymore as i'm sure @Conjured Entertainment would like to share his full script when it is done but "


Please, share.

I am brand new to Lua, and all I am doing right now is sharing what little I have learned so far, which is not much yet. I have only spent a few hours here and there looking at the stock scripts and the info at the Lua website. It's not that I am trying to hold back on the script to protect any tricks or secrets or anything. It's just that I am such a noob at Lua that I want to make sure that any script I post (however simple) is half decent and not showing people the wrong way to do things. I have to admit that I am a sloppy coder and sometimes do things the long way, but I can usually get my scripts to do something close to what I intended. Anyway, my scripts in Lua are probably not going to be the best ones to learn from for quite some time. I am hoping to be a full fledged Lua geek by the time Lee gets Reloaded where he is aiming though, which won't be that far off. I am just glad to be using reloaded now, so I can evolve with it.



EDIT

Here is a peek at the scripts so far, and you are going to laugh at how simple it is and how much is right out of the stock scripts. (see attachment)

These are really basic, so IF you place them too close to each other THEN you may run into trouble.

I did not need the \n in the prompts. That was part of a test and I forgot to take it out. Sorry.

The activated = 0 initialization wasn't needed either. I was experimenting with that too and once again forgot to take that out. That won't hurt anything for now though, and I might need it later, so...

AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 9th Feb 2014 06:52 Edited at: 9th Feb 2014 08:45
Ahh sweet cheers, i did start working on one and i am just waiting for alpha 1.0045 to re download (had too many issues with 1.005 and just have some quick new scripter questions for anyone that might answer, and conjured your scripts help me identify some problems i had already so thankyou



well first here's the script:

note the variable currentcash is declared in another script







and my questions:

1. is the detect if player pushed key at all needed in there

ok i have removed my question for math.random as i have just been testing and comfirmed that using:



currentcash = currentcash + (math.random(10,50) * 10);



will give you nice clean numbers in multiples of 10 i.e will generate a random number between 10 and 50 such as 14, then multiply it by 10 to form 140. Just thought would put this here if anyone was wondering like i was before

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
BlackFox
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 9th Feb 2014 07:09
Quote: "Has anyone else started a cash system for reloaded yet?"




Hi CE,



We actually have a full inventory system we ported from Classic FPI (our major development Ancient Tombs) to LUA. The system allows for buying/selling, cash, food, and experience. Your cash system looks great- you are in the zone. Give it time/patience and you will be able to spit these out in no time.



Best of luck.



There's no problem that can't be solved without applying a little scripting.
Jerry Tremble
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 9th Feb 2014 16:00
Thanks, Conjured,for sharing that! And you're right, it is ridiculously simple, which I guess many things are once you see and understand them. This should be easily adapted for many uses.
PM
J0linar
GameGuru TGC Backer
14
Years of Service
User Offline
Joined: 3rd Feb 2010
Location: Vienna, AT
Posted: 9th Feb 2014 17:35
@Conjured

thats really nice and thansk for sharing it



it would be great if someone takes a look at porting the

Nazi Zombies System by Gencheff

http://forum.thegamecreators.com/?m=forum_view&t=178003&b=23

with barriers - now th
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Feb 2014 18:19
@conjured that is pretty much exactly what i have so i think it's fine for a basic setup (obviously things will get better when inventory is included and such, i will hopefully post some scripts very soon on that and more) and as it was your thread i didn
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Feb 2014 04:17 Edited at: 10th Feb 2014 04:18
Quote: "and my questions:

1. is the detect if player pushed key at all needed in there"




Quote: " (and i think what may be confusing u is it only counts "keypressE" as true while it is actually being pressed (i.e. it automatically resets back to false when u let go of the E key)"




Right.

I don't think your script needs that, because ....



-- Detect if player push the E key

if g_KeyPressE == 0 then

pressed = 0;

end



... "if g_KeyPressE == 0" is actually checking to see if the key has been released, not pressed. And, in your case the script doesn't need to know that.



Your script does check for the key press though, so maybe the comment could be saved and moved up to the "if g_KeyPressE == 1" part of the script.

AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 10th Feb 2014 07:26 Edited at: 10th Feb 2014 07:31
thanks here's the revised script





and just a quick question again the Destroy(e) doesn't seem to be working for me, after i press E and pickup the cash, the entity is still there (no longer usable, but still there), anyone else have this problem?



and sorry but one last thing im also trying to develop a leveling system but i'm not sure how to write it so that it picks up your level based on experience.



i.e 100xp = level 1, 200xp = level 2 and so on, basically i need to read the experience variable and modify the level variable based on that or is there a better way to go about this??

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Feb 2014 13:36
if u set the entity to static mode (selecting yes in the properties in game) will make the entity not get deleted, might be a few other options there that have similar effects... if u compare the settings to a standard collectable entity (medpac / ammo etc) it might help



as for experience it depends how flexible you want the system to be, if each level is a flat 100xp apart for example u can simply check exp and divide by 100 and get the level from that

if u want the exp amount needed for each level to change i.e 100xp for level 1, 500xp for level 2, 800xp for level 3 etc then it'll take more work (this is how mmo's generally handle exp)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Jerry Tremble
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 11th Feb 2014 05:43
Destroy(e) isn't working for me, either. I'm sure it will in the future. Hoping sooner rather than later. It seems they are opening up full engine control through Lua in the future, so learn it, eat it, drink it, and sleep it!
PM
AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 11th Feb 2014 06:12
@smallg yeah im definatley looking at the more complicated one and not just dividing the exp, just not sure how to make lua read it,



i have tried to use



if exp > 200 and < 299 then

charlevel = 2

if exp > 300 and < 399 then

char
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 11th Feb 2014 19:30 Edited at: 11th Feb 2014 20:02
edit; ok here's an example exp script



this will check for exp and set the level (personally i would use a tree / plant / building for this script as u need it to be something that will always be ingame - i.e not destroyed)





now u need a way of increasin exp (this is simple but currently i dont think there's a way to make it work with killing enemies (i tried setting it on the disappear script but it doesnt work) so i just used collectables for an example.



and finally just set
as global variables.



example vid





@Jerry if u pick up a default medpac or other collectable does it vanish?

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 11th Feb 2014 23:46 Edited at: 12th Feb 2014 00:08
Quote: "thanks here's the revised script



+ Code Snippet



and just a quick question again the Destroy(e) doesn't seem to be working for me,"




I notice that you removed the Collected(e)

Try putting that back and see what happens.



Quote: "i have tried to use



if exp > 200 and < 299 then

charlevel = 2

if exp > 300 and < 399 then

charlevel = 3



and so on but this just crashes, any idea's?

"




Are you remembering to END the if statements???

AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 12th Feb 2014 03:48 Edited at: 12th Feb 2014 11:54
ok this is what i've got now:







but i get the error when i try to run:

scriptbank\displaylevel.lua:26:'then' expected near '='



p.s setting the static on the cash to no, now works perfectly for destroy(e), thanks

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home
Conjured Entertainment
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 12th Feb 2014 23:00 Edited at: 12th Feb 2014 23:18
Quote: "

if charlevel = 5 then

chardiscount = 0.8

end"




Shouldn't that be == ?



if charlevel == 5 then



Shouldn't we use two equal signs for the condition and only one equal for an assignment?



Couldn't you condense that a bit anyway as in ...



if charexp > 850 then

charlevel = 5

end

if charlevel == 5 then

chardiscount = 0.8

end



...becomes this...



if charexp > 850 then

charlevel = 5

chardiscount = 0.8

end



...and don't forget the e's in the variable name in the prompt.

AuShadow
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 13th Feb 2014 12:18
worked a treat, just started a new thread showcasing all the scripts you guys helped me with and smallg and Conjured Entertainment you both get a big mention as without you guys helping me i don't even want to think about how long it would have taken me to work out where i went wrong, so thank you both very much,



p.s will have a video of the scripts working up later roughly 46 minutes from the time of this post

Feel free to visit and edit the public FPSCR resource wiki page



http://fpscrresource.wikispaces.com/home

Login to post a reply

Server time is: 2024-05-06 08:18:17
Your offset time is: 2024-05-06 08:18:17