Hi all. Here is a little example of what I have been playing about with of late. I was inspired by AUShadows Xp scripts and decided to look into them. I have improved them and added some extra stuff in to meet with the farming scenario.
The scripts are still rough and would really need more work for a full game, at least if they were used heavily, but as a wip it seems good enough to at least show. I definitely have to spend a little more time with Lua than I have so far. I keep waiting for a stable release first though, it does not encourage one to go too mad when you pretty much know your work could be lost quite easily. Still, it's all good practise I suppose!
If there is interest I will do another video on how the scripts were altered and also release the scripts for people to see. I worked form AUShadows scripts to start with and just rewrote them a little to make them less set in stone and more automatic. Take a look at those to get an idea.
Edit in fact here is the Xp script for you to peruse anyway.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collected experience
-- Standard player distance math
function xp_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
if charlvl<levelmax then
Prompt("Press E to pickup. XP = " .. charexp .. " Level " .. charlvl .. " XP Needed for level " .. charlvl + 1 .. " " .. levelxp - charexp .. " XP" .. " You have " .. potatoes .. " Potatoes.");
end
if g_KeyPressE == 1 then
if charlvl<levelmax then
-- makes the exp a random number between 10 and 50 and then multiplies it by 10
charexp = charexp + (math.random(40,70) * 10);
potatoes = potatoes + (math.random(1,4));
PlaySound0(e);
Destroy(e);
else
Prompt("Level Max reached." );
end
end
end
end
Obviously there are some globals to be added to the main global file and other scripts also, but I will include those when I go into detail.