ok after many hours of reading other scripts and the forums I have managed to come up with the following addin's to smallg script above with a lot of help and tips from smallg/avram and aushadow scripts here is a video of them working.
will add the scrips below for you all to view/use if you like
global.lua addins
charexp = 0
charlvl = 1
craftitem1 = 0
craftitem2 = 0
craftitem3 = 0
crafteditem = 0
craftedammo = 0
the exp script (aushadows with slight changes to exp amount)
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collected experience
-- Standard player distance math
function exp_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
--Display Text
Prompt("Press E to pickup exp, exp =" .. charexp);
if g_KeyPressE == 1 then
-- makes the exp increase by 10-25, i needed a controlled number for testing
charexp = charexp + (math.random(10,25) *2);
PlaySound0(e);
Destroy(e);
end
end
-- Detect if player push the E key
if g_KeyPressE == 0 then
pressed = 0;
end
end
the show player lvl script (aushadows)
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- character level display
function displaylevel_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));
-- Read Variable charexp and determan level of character and write it to charlevel
if charexp > 250 then
charlvl = 2
end
if charexp > 400 then
charlvl = 3
end
if charexp > 600 then
charlvl = 4
end
if charexp > 850 then
charlvl = 5
end
if charexp > 1000 then
charlvl = 6
end
if charexp > 1250 then
charlvl = 7
end
if charexp > 1600 then
charlvl = 8
end
if charexp > 2000 then
charlvl = 9
end
if charexp > 3000 then
charlvl = 10
end
if PlayerDist < 100 then
Prompt("Character Level is " .. charlvl);
end
end
the crafting bench script (smallg script with some slight changes) called "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
the crafted ammo script (smallg script, only pistol ammo at present) called "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
this is a gunpowder script (smallg script with slight changes)called "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
a script for scrap metal (smallg script with slight changes) called "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
this is the script for bullet casings (smallg script with slight changes) called "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
ok add the global.lua to your global.lua file in script bank (make a back up)
add the rest as new scripts to your script bank
now to get the scripts to work just pick an object to be the items gunpowder, scrap metal, bullet casings and change the "main" to 1 of those scripts named craftitem1-3 (you could probably change the names of craftitem1-3 and still get it to do the same thing, I just didn't know how and gave up lol), the item can be destroyed but stay on the map if wanted by changing it from a static or dynamic entity. like the bin bags disappeared and some of the boxes stayed behind. (but this is a bit hit and miss in beta 5).
after getting the different items on your map hide the item holding the craftedammo.lua script somewhere under ground or high up on a mountain top, if you bury it in the terrain leave a marker there for remembering it for if you need it again.
if any1 knows of abetter way to do all this or thinks the code can be cleaned up post your changes here please for all to see
thanks a lot to all involved with this little test run and enjoy the scripts im sure they can be changed to make food and health and more perhaps?!.. I hope I didn't forget anything here to get them to work lol...
evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.