Scripts / crafting scripting possible yet or in future?

Author
Message
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 13th Apr 2014 23:19 Edited at: 13th Apr 2014 23:21
ok found something out, and just incase any1 else was having trouble getting the health to work, the cookmeal.lua HAS to be linked to a collectable health entity from stock media. i was trying to get it to work with a plate of food and having little success, i could make the meal and use ingredients but not get any health added.



@smallg have gone back to the original cooker.lua and cookmeal.lua for now, cant make it work 100% right so far, just wont make the meal not enough items, ohwell its good to know you got it to work so its me not the scripts or the engine lol.



thanks alot for all your time and effort thanks for the info tips advice and links m8 nice 1 both



would any of you mind if these got added to the reloaded wiki guys?

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Apr 2014 00:34
thanks again avram i will check that nil error tomorrow which is not something i would have considered myself so nice call... i already did add the other code but it was that particular line causing the issue when i was testing - i should have been more specific



@hood i may be wrong but from your post i would say u have changed the recipe if statement and not quite got it correct

did u perhaps put

Quote: "if fooditem1 == 3 and fooditem2 == 5 and fooditem3 == 3 then"
?

it needs to be >= instead of ==



if not please post up your script and i will check it





and yh the original medpac models contain an fpe file which has the information stored about how much HP to restore - same for the ammo.

i'm sure there is a way to make an fpe file for your own models but i'm not the person to ask about that.

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 01:02
ok here are the originals for cooking and adding health they all work fine without the timer added.



cooker.lua





cookmeal.lua





now as i say these work fine without timer added they cook and add health using items collected. please note, these codes are just your craftedammo and crafter renamed with some number changes made. no idea why your altered codes of these with the timer dont function properly? the not subtracting items and adding health while propting not enough items when you have 100's of each needed, probably i missing something ?.

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 17:10
ok so i couldnt figure what was going wrong with the timer variation of the cooker and cookmeal scripts...



so i worked on something else instead to see if it was possible, and it was/is

here is a short vid on what ive done with your crafter and craftedammo scripts smallg m8 hope you like it as it worked no problems 1st time with just 3 or 4 renames and a global variable added.







i am thinking now that all it takes is the corrisponding entity for each item you want to use so a shotgun in your hands would need the script on a shotgun to give it to you?. not tested this is just a 1st run of the day so far.

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Apr 2014 17:32
Edit your entity .fpe file (or copy only .fpe file under new name if you want to keep both entities) with your favorite text editor (e.g. Notepad, Notepad++. Sublime Text, ...) and add edit these variables:



Quote: "isweapon = 0

isammo = 0

ishealth = 1



quantity = 25"




To use entity as ammo requires that you have ammo for this entity so I'll skip it. For ammo set isammo to 1 and others to 0, and for health set isammo to 1 and others to 0. Then under quantity change the amount of ammo/health user will get when he gets the entity. Interesting stuff is that you can have e.g. expired food with negative quantity, and that will do damage to the player

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Apr 2014 17:37
yes that should work so long as u set different variables to trigger on/off depending on recipe



i did get the timer working now but i had to move it over to the crafting table as it just wouldnt talk correctly from the other file, however it works quite nicely now



cooker.lua





cookmeal.lua





p.s. and the problem with that other code was that u set cookmeal = 100 in cookmeal.lua when my code requires it to check between 1 and 0 (in coding 1 is normally used to specify true/yes/on - and 0 to mean false/no/off)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 18:24
cool smallg m8 thanks will try them out shortly



have made a magnum appear as player weapon now in the crafting a gun scripts

so now we can craft ammo, a weapon and health via a meal. thanks to you guys that is, all i did was change some names and add a few globals .







this stuff is getting interesting ...



scripts below for a working make weapon and add to player





global variables to add





guncrafter.lua







craftgun.lua







gunparts1.lua







gunparts2.lua







gunparts3.lua





i think thats everything, if you put craftedgun.lua onto a pistol you will make a pistol, if you put in on shotgun you will make a shotgun just replace the "main" with the craftedgun.lua script and the guncrafter.lua onto a table "main" and then put the other .lua scripts on various entities of your choice it should all work fine . happy crafting weapons all



and thanks again to smallg avram dvader and aushadows for scripting ideas help and work done so far truely awesome of you all..

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 19:02




nice 1 smallg that worked a treat thanks

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Apr 2014 20:05
it is so much nicer when u can directly control how things work like this, scripting sure is worth learning.



just wait til we have more control and then imagine what u can make



p.s. if im being picky your code for the if statement should match the values u edit the varibles by otherwise it's still technically possible to create the weapon even if u only have 1 of each (although i realise from your current pickup codes that isnt an issue it may become one in future if u did add more recipes or different pickup amounts etc)





should be something like





continue having fun testing out new things!

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 20:40
ok m8 thanks for further advice, would be nice to be able to code my own scripts so will defo look into learning lua from soomewhere. until then though do you think i could get that script for a % done timer please m8 to add to the process of crafting a weapon? it does it so fast right now i think it would probably be better to have the %timer attached some place. (not sure if you did put that code into forum post in this thread earlier or not sorry if you did).





btw can we add these to the wiki m8?, im sure aushadow would be happy to have them there?!.

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Apr 2014 21:53 Edited at: 14th Apr 2014 22:01
ok, @smallg, just a small remark:



in your code:







This can be written as:









Or shorter:







The :start() method will check if timer is already running and start timer only if it is not running.



...or even shorter:











I don't want to look like I'm nagging all the time, I just love short, readable and useful code



I have started working on video tutorial(s) about LUA in FPSC:R where I should explain in details how FPSC is calling our custom lua functions, but I'm not even sure if (not when) it will be completed, as I suck in both explaining things and making videos. Or I will just make some neat examples with commented code and post youtube video along with the code.

Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Apr 2014 22:11
@hood: For percent you can use this:





[href=http://fpscrforum.thegamecreators.com/?m=forum_view&t=207960&b=2]Visual LUA designer for FPS
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Apr 2014 22:21 Edited at: 14th Apr 2014 22:26
thanks!, does the
Quote: "if not"
work for all your functions as i was trying to figure out how to tell if something was false, normally i would check for something like
Quote: "if timer:running() == 0"
like the normal FPSCR:LUA style but that didnt seem to work hence why i was using the else XD

i did try reading the timer info page u have but there's no usage example i see that has any such info (however the info it does have is great!), it would be great if when you do make some further tutorials you could add some examples - personally i find it much easier to read the code than trying to understand it in words.





@hood ok so here is your gun code with a timer

craftedgun.lua





guncrafter.lua





as for the wiki, sure if u want to add anything it's fine by me.





edit: just stole avrams line for easier % calc

also no idea why it gives the 39.9999% while all the others work fine... weird XD

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 14th Apr 2014 22:47
just ran the new codes and it works perfectly for me 1st time round ...

it did show 39.99995d or something but carried on counting up normally after that , cant believe how well it all turned out with this thread so far i was not sure if any of it was possible so early into reloaded dev.. but you guys sure know your stuff and made this all come together so again BIG THANKS to all for inspiration help advice and all the scripts you put together smallg,avram,dvader,aushadow thankyou





i will be putting together a small lvl and making a video of them working together and post it aswell as put all the scripts used into 1 place for ease of use if any1 wants to use them, later on tonight.

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Apr 2014 22:49
Strangely enough, LUA's math library doesn't have "round()" method to round numbers, but I have made something that can do the job (haven't tested):







As for the "not" in if statements, it works for all "boolean" values (true/false), and since aTimer:running() returns boolean, you can use it there, but you can't check if it is 0, as zero is not same as false.



To check if something is false, you can use any of these methods:





AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 14th Apr 2014 23:20
Math.floor and math.Ceil will round numbers down or up respectively

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 14th Apr 2014 23:36
Yeah, but what if it's 5.002 and you use math.ceil()? It'll round to 6



It doesn't matter in this case if it shows 6% instead of 5%, but it might matter in some other cases.

almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 15th Apr 2014 03:39 Edited at: 15th Apr 2014 04:38
ok a final cut of the crafting so far on this vid







the globals used in these scripts add to global.lua





this code goes to the very bottow of the global.lua, but you need avrams timer tools for it all to work!!.





avrams tools can be found here http://fpscrforum.thegamecreators.com/?m=forum_view&t=208181&b=2 this will allow timing scripts to function with the engine.



now for the actual scripts to be added to your script bank.



the cooker script, used on a suitable model's "main" in model settings (place model right click it and change the main to cooker.lua).

save this script as cooker.lua (make sure its not a txt file)





now the meal itself, it has to be attached to a collectable health pack from stock entities of the reloaded engine, and is named cookmeal.lua as before change the "main" to this script.





now for cooking ingredients I have 3 set for making health food for player but it can be more or less. same process for picking suitable models change the "main" on 1 and then dublicate for more than 1 of each. (don't place loads then change scripts.. you be there alonger time lol).

name this script fooditem1.lua



followed by fooditem2.lua



followed by fooditem3.lua



not that's all you need for the crafting of food and harvesting in 1 enjoy

-----------------------------------------------------------------------------

gun making scripts are not much different from cooking just different names and globals, plus a change from addplayerhealth to addplayerweapon in the cookmeal.lua script.



guncrafter.lua





craftedgun.lua





gunparts1.lua





gunparts2.lua





gunparts3.lua





to make a different gun from the pistol add the craftedgun.lua script to any of the other guns that are weapons in the reloaded engine. just pick 1 add the script onto it and that gun will be made. (these scripts used the pistol as a basic test and would have to have some wording changed here and there for other bigger weapons for example).

--------------------------------------------------------------------------



ammo crafting is just the same as the other 2 lots of crafting you can change the ammo types made by changing the ammo box and adding craftedammo.lua to it. find ammo boxes in the weapons lists of the reloaded engine stock media. (remember you have to use these stock media for making the scripts work.)



crafter.lua





craftedammo.lua





craftitem1.lua





craftitem2.lua





craftitem3.lua





that's it, all the scripts ready to use. enjoy playing with beta's with crafting from now on .

at some point there will be away to add player inventory and display items in it I would guess but for now this will do nicely for me ..

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Apr 2014 20:03
nice video there, nice to see it all together like that, amazing how such little bits and pieces became a pretty solid start - with a few quests and replacement models that could easily become a game in it's own right... who doesnt love a bit of farming while killing bad guys?





if = false... how did i miss that?

been fun working with u 2



p.s. is it just me or does it sound like she says she's going to milk a cow during that song? XD

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
almightyhood
11
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 15th Apr 2014 20:53
Quote: "p.s. is it just me or does it sound like she says she's going to milk a cow during that song? XD"




hahaha im not to sure m8 tbh lol it was fitting in with vid timewise and I found that track by name just for the crafting items link, never heard of the artist or the song before yesterday lol. I will give it another listen now .



Quote: "been fun working with u 2 "


its been fun and educational, the best way to learn is through fun I think so ty all again .



Quote: "nice video there, nice to see it all together like that, amazing how such little bits and pieces became a pretty solid start - with a few quests and replacement models that could easily become a game in it's own right... who doesnt love a bit of farming while killing bad guys? "


yeah just needs an inventory system screen and a crafting screen some work on extra recipes later on but it is a nice lot of scripts and ready for beta6 also amazing timing lol.



so anyways in that im looking for good pay or free hud making software ready for when we can use them, no idea whats involved so hopefully another fun learning experience any tips any1?

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 16th Apr 2014 10:54
TGC has one but never used it so no idea what its like , would always like to hear of some good ones

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

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-12-21 18:51:34
Your offset time is: 2024-12-21 18:51:34