ok a final cut of the crafting so far on this vid
the globals used in these scripts add to global.lua
charexp = 0
charlvl = 1
craftitem1 = 0
craftitem2 = 0
craftitem3 = 0
crafteditem = 0
craftedammo = 0
craftedgun = 0
gunparts1 = 0
gunparts2 = 0
gunparts3 = 0
cookmeal = 0
cookeditem = 0
fooditem1 = 0
fooditem2 = 0
fooditem3 = 0
levelmax=10
levelxp = 4000
upgradeskill=8500
potatoes=0
potatoestore=0
potatoesold=0
greetings=0
beetroots=0
this code goes to the very bottow of the global.lua, but you need avrams timer tools for it all to work!!.
-- Load Avram's FPSC:R toolkit
aConfig = aConfig or { path = "scriptbank/Avram/" }
require (aConfig.path .. "bootstrap.lua")
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)
function cooker_main(e)
local this = aEntity:new(e, "cooker")
local cmTimer = aTimer:new(e, 30) --basically a countdown from 20 (change the 20 to whatever value u require)
if cmTimer:running() then
else
cmTimer:start()
end --end timer check
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt(" potato = " .. fooditem1 .. " beetroot = " .. fooditem2 .. " redroot = " .. fooditem3 .. " , Cook meal " .. cookeditem .. " times so far , time til next meal = " .. cmTimer:left() .. " , charexp = " .. charexp)
if g_KeyPressE == 1 then
if cmTimer:expired() then
if fooditem1 >= 3 and fooditem2 >= 5 and fooditem3 >= 7 then
cmTimer:reset()
fooditem1 = fooditem1 - 3
fooditem2 = fooditem2 - 5
fooditem3 = fooditem3 - 7
cookeditem = cookeditem + 1
cookmeal = 1
charexp = charexp + 50
else
Prompt("Not Enough Ingrediants")
end --end of recipe check
else
Prompt("Still need to wait " ..cmTimer:left() .. "s before you can eat again")
end --end timer running check
end --end of input check
end --end of distance check
end --end of main
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.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Cooks meal
function cookmeal_main(e)
local this = aEntity:new(e, "cookmeal")
if cookmeal == 1 then
PlaySound0(e);
AddPlayerHealth(e);
cookmeal = 0
end --end cookmeal = 1
end --end func
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
function fooditem1_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("potato = " .. fooditem1 .. " , press E to collect , charexp = " .. charexp) --added the charexp display here
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
fooditem1 = fooditem1 + 3 --player picks up 3 of fooditem1/potato
charexp = charexp + 10 --increases exp by the amount given
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then --used to delay the player input
pressed = 0
end
end
end
followed by fooditem2.lua
function fooditem2_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("beetroot = " .. fooditem2 .. " , press E to collect , charexp = " ..charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
fooditem2 = fooditem2 + 5
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
followed by fooditem3.lua
function fooditem3_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("redroot = " .. fooditem3 .. " , press E to collect , charexp = " .. charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
fooditem3 = fooditem3 + 7
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
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
function guncrafter_main(e)
local this = aEntity:new(e, "guncrafter")
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt(" gun grip = " .. gunparts1 .. " small gun parts = " .. gunparts2 .. " small gun barrel = " .. gunparts3 .. " , Crafted gun " .. crafteditem .. " times so far , charexp = " .. charexp)
if g_KeyPressE == 1 and pressed == 0 and craftedgun == 0 then
pressed = 1
if gunparts1 >= 1 and gunparts2 >= 3 and gunparts3 >= 1 then
gunparts1 = gunparts1 - 1
gunparts2 = gunparts2 - 3
gunparts3 = gunparts3 - 1
craftedgun = 1
--Display Text
else
Prompt("Not Enough Items")
end --end of recipe check
end --end of input check
end --end of distance check
if g_KeyPressE == 0 then
pressed = 0
end --end of reset to input
end --end of main
craftedgun.lua
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Crafts A gun
function craftedgun_main(e)
local this = aEntity:new(e, "craftedgun")
local cgTimer = aTimer:new(e, 10) --basically a countdown from 10
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if craftedgun == 1 then
cgTimer:start()
if cgTimer:expired() then
PlaySound0(e);
AddPlayerWeapon(e);
crafteditem = crafteditem + 1
charexp = charexp + 500
craftedgun = 0
cgTimer:reset()
cgTimer:stop()
else
local percent = 100 - ((cgTimer:left() / cgTimer.countdown) * 100);
Prompt("Crafting " .. percent .. "%")
end --end timer expired check
end
end
gunparts1.lua
function gunparts1_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("gun grip = " .. gunparts1 .. " , press E to collect , charexp = " .. charexp) --added the charexp display here
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
gunparts1 = gunparts1 + 1 --player picks up 1 of gunparts1/gun grip
charexp = charexp + 10 --increases exp by the amount given
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then --used to delay the player input
pressed = 0
end
end
end
gunparts2.lua
function gunparts2_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("small gun parts = " .. gunparts2 .. " , press E to collect , charexp = " ..charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
gunparts2 = gunparts2 + 3
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
gunparts3.lua
function gunparts3_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("small gun barrel = " .. gunparts3 .. " , press E to collect , charexp = " .. charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
gunparts3 = gunparts3 + 1
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
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
function crafter_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt(" gunpowder = " .. craftitem1 .. " scrap metal = " .. craftitem2 .. " bullet casings = " .. craftitem3 .. " , Crafted ammo " .. crafteditem .. " , charexp = " .. charexp.." , times so far")
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
if craftitem1 > 0 and craftitem2 > 0 and craftitem3 > 0 then
craftitem1 = craftitem1 - 3
craftitem2 = craftitem2 - 10
craftitem3 = craftitem3 - 70
crafteditem = crafteditem + 1
craftedammo = 1
charexp = charexp + 50
--Display Text
else
Prompt("Not Enough Items")
end --end of recipe check
end --end of input check
end --end of distance check
if g_KeyPressE == 0 then
pressed = 0
end --end of reset to input
end --end of main
craftedammo.lua
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Crafts Ammo
function craftedammo_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if craftedammo == 1 then
PlaySound0(e);
AddPlayerAmmo(e);
craftedammo = 0
end
end
craftitem1.lua
function craftitem1_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("gunpowder = " .. craftitem1 .. " , press E to collect , charexp = " .. charexp) --added the charexp display here
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
craftitem1 = craftitem1 + 3 --player picks up 3 of craftitem1/gunpowder
charexp = charexp + 10 --increases exp by the amount given
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then --used to delay the player input
pressed = 0
end
end
end
craftitem2.lua
function craftitem2_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("scrap metal = " .. craftitem2 .. " , press E to collect , charexp = " ..charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
craftitem2 = craftitem2 + 10
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
craftitem3.lua
function craftitem3_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
Prompt("bullet casings = " .. craftitem3 .. " , press E to collect , charexp = " .. charexp)
if g_KeyPressE == 1 and pressed == 0 then
PlaySound0(e);
craftitem3 = craftitem3 + 70
charexp = charexp + 10
pressed = 1
Destroy(e);
end
if g_KeyPressE == 0 then
pressed = 0
end
end
end
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.