Page 1 of 1

[Mod] XP [1.0]

PostPosted: Thu Oct 04, 2012 18:08
by jordan4ibanez
This adds in XP orbs, and rewards from xp.

How does one get xp? Well you have to assign some ores to the group xp=1 for this to work. when you dig an ore with xp=1 group, you get an orb and you just might level up.

a player loses all xp on death.

There is a neat level up sound.

SCREENSHOT
Image

Download

License: dwtfywt

PostPosted: Thu Oct 04, 2012 18:14
by PilzAdam
Yay! We are finaly Minecraft! </ironic>

PostPosted: Thu Oct 04, 2012 18:47
by Mito551
PilzAdam wrote:Yay! We are finaly Minecraft! </ironic>


+1

PostPosted: Thu Oct 04, 2012 19:05
by jordan4ibanez
PilzAdam wrote:Yay! We are finaly Minecraft! </ironic>

your game mode uses the entire minecraft texture pack, why would you even say that?

PostPosted: Fri Oct 05, 2012 01:06
by leo_rockway
jordan4ibanez wrote:This adds in XP orbs, and rewards from xp.

How does one get xp? Well you have to assign some ores to the group xp=1 for this to work.


I'm sorry, I don't see where to add this. Can you be more specific? Thank you.

PostPosted: Fri Oct 05, 2012 01:14
by jordan4ibanez
leo_rockway wrote:
jordan4ibanez wrote:This adds in XP orbs, and rewards from xp.

How does one get xp? Well you have to assign some ores to the group xp=1 for this to work.


I'm sorry, I don't see where to add this. Can you be more specific? Thank you.

in an ore's group, like {cracky=1,chewy=2,xp=1}

PostPosted: Fri Oct 05, 2012 01:29
by leo_rockway
jordan4ibanez wrote:
leo_rockway wrote:
jordan4ibanez wrote:This adds in XP orbs, and rewards from xp.

How does one get xp? Well you have to assign some ores to the group xp=1 for this to work.


I'm sorry, I don't see where to add this. Can you be more specific? Thank you.

in an ore's group, like {cracky=1,chewy=2,xp=1}


Oh, gotcha. Thanks a lot.

PostPosted: Fri Oct 05, 2012 03:58
by Mito551
is there any particular usage of xp at the moment?

PostPosted: Fri Oct 05, 2012 03:58
by jordan4ibanez
Mito551 wrote:is there any particular usage of xp at the moment?

you get rewards from it

PostPosted: Fri Oct 05, 2012 04:00
by Mito551
what kind of rewards? how do you use them. i'm not convinced

the mc lacks it as well. proper xp usage.

PostPosted: Fri Oct 05, 2012 07:09
by leo_rockway
Mito551 wrote:what kind of rewards?



level1 = 100
level1_drop = "default:steelblock 10"

level2 = 200
level2_drop = "default:steelblock 99"

level3 = 300
level3_drop = "default:mese 1"

level4 = 400
level4_drop = "default:mese 2"

level5 = 500
level5_drop = "default:mese 10"

level6 = 700
level6_drop = "default:mese 20"

level7 = 1000
level7_drop = "default:mese 30"

level8 = 1400
level8_drop = "default:mese 50"

level9 = 1800
level9_drop = "default:mese 70"

level10 = 2500
level10_drop = "default:mese 99"

PostPosted: Fri Oct 05, 2012 08:09
by Mito551
imo, that's ridiculous. but ok, do it your way. a skill tree would be nice( though i don't think it's possible through lua) with good working skills. like fire ball XD

PostPosted: Fri Oct 12, 2012 17:50
by snakevenom
how can you assign ores to give you xp?

PostPosted: Fri Oct 12, 2012 18:00
by tinoesroho
Either a) edit init.lua or b) write a mod that redefines the defaults

PostPosted: Fri Oct 12, 2012 22:13
by SegFault22
Hmm, this could be useful - in the future when an experience system and job system is implemented (RPG forks of minetest), experience can add up as one does something according to their job (knight gives XP for killing mobs/enemies with a sword, giving special abilities like cover and guard as the levels increase; miner gives XP for mining ores and making new pickaxes, could increase drop rate from ores; etc etc etc.), causing them to be able to equip a job and abilities depending on the job (knight/mage gives 1 open slot for abilities and the other is for the default ability of that job; ''bare'' gives 2 free slots for abilities).
Thank you for making this great addition to Minetest.

PostPosted: Sat Oct 13, 2012 01:40
by jordan4ibanez
SegFault22 wrote:Hmm, this could be useful - in the future when an experience system and job system is implemented (RPG forks of minetest), experience can add up as one does something according to their job (knight gives XP for killing mobs/enemies with a sword, giving special abilities like cover and guard as the levels increase; miner gives XP for mining ores and making new pickaxes, could increase drop rate from ores; etc etc etc.), causing them to be able to equip a job and abilities depending on the job (knight/mage gives 1 open slot for abilities and the other is for the default ability of that job; ''bare'' gives 2 free slots for abilities).
Thank you for making this great addition to Minetest.

no problem bud, i wrote a better one, i will release it later though

Re: [Mod] XP [1.0]

PostPosted: Fri Nov 14, 2014 16:10
by Spirosxk
Hi
I get this error and the server crashes when i activate the mod in my server. In singleplayer mode is working. I use Minetest version 4.10.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
terminate called after throwing an instance of 'ServerError'
  what():  /home/spiros/.minetest/mods/experience/init.lua:68: attempt to index global 'xp' (a nil value)
stack traceback:
   /home/spiros/.minetest/mods/experience/init.lua:68: in function '?'
   /usr/share/minetest/builtin/game/register.lua:348: in function </usr/share/minetest/builtin/game/register.lua:336>
Aborted

Re: [Mod] XP [1.0]

PostPosted: Tue Dec 16, 2014 15:14
by DevilRomeoAPLUS
Nice Mod

Re: [Mod] XP [1.0]

PostPosted: Fri May 06, 2016 06:37
by burli
Is this mod not compatible with better hud and hunger? I tried it and the xp bar is not shown

Re: [Mod] XP [1.0]

PostPosted: Sat May 07, 2016 18:50
by TailsTheFoxDoes MT
jordan4ibanez wrote:This adds in XP orbs, and rewards from xp.

How does one get xp? Well you have to assign some ores to the group xp=1 for this to work. when you dig an ore with xp=1 group, you get an orb and you just might level up.

a player loses all xp on death.

There is a neat level up sound.

SCREENSHOT
Image

Download

License: dwtfywt

Can u make it work for mobs upon death?

Re: [Mod] XP [1.0]

PostPosted: Sat May 14, 2016 04:09
by D00Med
Really nice mod!
I made some changes, which might be useful.
I made the texture much smaller(to be closer to the default textures) and added a hudbar. Fewer xp is required to gain levels but some of the rewards aren't as valuable(in my opinion).
Also, if anyone wants mobs from mobs_redo to drop experience when they die, add this to line 287 of api.lua in the mobs folder:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.env:add_entity(pos, "experience:orb")

Re: [Mod] XP [1.0]

PostPosted: Sat May 14, 2016 07:06
by TailsTheFoxDoes MT
D00Med wrote:Really nice mod!
I made some changes, which might be useful.
I made the texture much smaller(to be closer to the default textures) and added a hudbar. Fewer xp is required to gain levels but some of the rewards aren't as valuable(in my opinion).
Also, if anyone wants mobs from mobs_redo to drop experience when they die, add this to line 287 of api.lua in the mobs folder:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.env:add_entity(pos, "experience:orb")

ONLY mobs_redo?

Re: [Mod] XP [1.0]

PostPosted: Sat May 14, 2016 20:41
by D00Med
It would have to be placed somewhere else for other mob mods. For creatures, I think you would need to add this into the code for each monster/animal:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if self.object:get_hp() < 1 then
minetest.env:add_entity(pos, "experience:orb")
end

I haven't tried it though.
For other mob mods it would be similar -just look for the effects after a mobs death and add the code there.

Re: [Mod] XP [1.0]

PostPosted: Thu Jun 16, 2016 14:39
by MykieDoesStuff
I got errors...

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2016-06-16 10:35:46: [Main]: Using world specified by --worldname on the command line
2016-06-16 10:35:46: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2016-06-16 10:35:46: ACTION[Server]: Announcing to servers.minetest.net
2016-06-16 10:35:46: ACTION[Main]: Announcing to servers.minetest.net        .__               __                   __   
2016-06-16 10:35:46: ACTION[Main]:   _____ |__| ____   _____/  |_  ____   _______/  |_
2016-06-16 10:35:46: ACTION[Main]:  /     \|  |/    \_/ __ \   __\/ __ \ /  ___/\   __\
2016-06-16 10:35:46: ACTION[Main]: |  Y Y  \  |   |  \  ___/|  | \  ___/ \___ \  |  | 
2016-06-16 10:35:46: ACTION[Main]: |__|_|  /__|___|  /\___  >__|  \___  >____  > |__| 
2016-06-16 10:35:46: ACTION[Main]:       \/        \/     \/          \/     \/       
2016-06-16 10:35:46: ACTION[Main]: World at [C:\Users\Mykhaylo\Desktop\Server\minetest-0.4.14-win64\minetest-0.4.14\bin\..\worlds\Mykie]
2016-06-16 10:35:46: ACTION[Main]: Server for gameid="minetest" listening on 0.0.0.0:30000.
2016-06-16 10:35:57: ACTION[Server]: MykieDoesStuff [192.168.1.1] joins game.
2016-06-16 10:35:57: ACTION[Server]: MykieDoesStuff joins game. List of players: MykieDoesStuff
2016-06-16 10:35:57: WARNING[Server]: Assignment to undeclared global "xp" inside a function at ...14-win64\minetest-0.4.14\bin\..\mods\experience\init.lua:56.
2016-06-16 10:35:58: ERROR[Main]: Access denied. Reason: This server has experienced an internal error. You will now be disconnected.
2016-06-16 10:35:58: ERROR[Main]: ServerError: Runtime error from mod 'experience' in callback environment_Step(): ...14-win64\minetest-0.4.14\bin\..\mods\experience\init.lua:85: attempt to index global 'xp' (a nil value)
2016-06-16 10:35:58: ERROR[Main]: stack traceback:
2016-06-16 10:35:58: ERROR[Main]:    ...14-win64\minetest-0.4.14\bin\..\mods\experience\init.lua:85: in function <...14-win64\minetest-0.4.14\bin\..\mods\experience\init.lua:82>
2016-06-16 10:35:58: ERROR[Main]:    ...4-win64\minetest-0.4.14\bin\..\builtin\game\register.lua:369: in function <...4-win64\minetest-0.4.14\bin\..\builtin\game\register.lua:349>



Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--hudbar
minetest.register_on_joinplayer(function(player)
xp = io.open(minetest.get_worldpath().."/"..player:get_player_name().."_experience", "r")
            experience = xp:read("*l")
            xp:close()
local playername = player:get_player_name()
player:hud_add({
         hud_elem_type = "statbar",
         position = {x=0.5,y=1},
         size = {x=24, y=24},
         text = "experience_hud_bg.png",
         number = 50,
         alignment = {x=0,y=1},
         offset = {x=-300, y=-10},
         }
      )
xp_hud = player:hud_add({
         hud_elem_type = "statbar",
         position = {x=0.5,y=1},
         size = {x=24, y=24},
         text = "experience_hud.png",
         number = experience/20,
         alignment = {x=0,y=1},
         offset = {x=-300, y=-10},
         }
      )
end)



Any fix?

Re: [Mod] XP [1.0]

PostPosted: Thu Jun 16, 2016 20:42
by D00Med
Aaah serves me right for only testing on my subgame.
I had a quick look, and I don't really know how to fix it, I'll work on it though

Re: [Mod] XP [1.0]

PostPosted: Thu Jun 16, 2016 21:19
by Byakuren
You use a lot of global variables. This pollutes the global namespace and can cause problems if multiple mods use the same global variables names. Could you limit the global variables you introduce to just one with the same name of your mod, and change the others to local? You do use local variables in some places, so I assume that at least some of the global variables are a mistake.

Also, some design comments:
  • Instead of hard-coding level rewards, you could have a table mapping experience levels to rewards, and add a function for registering new rewards, which could be exposed for use by other modders by including it in your mod's table (experience). If you do this, the experience levels really need to be mapped to lists of rewards rather than just one reward, because otherwise you couldn't have multiple mods add a reward for the same level.
    • For extra flexibility, you can allow the registration of functions that take a new experience level as input and output a reward. This would allow you to do things such as recurring rewards.
  • Reading/Writing files is expensive, so don't open files every single server step. If you want one file per player, you can have a table mapping player names to their experience information. The information for a player's key gets loaded when the player joins, and unloaded (and written to file) when they leave. When you want to change something, just change it in the table, and it will get saved the next time it's written to file. If you want to make it safer, you can back up the player data every few seconds by running through each player's experience and writing it out.
  • I would prefer moving the experience collection logic to the experience orb's step function, rather than being in a global step.
  • Don't ever change a luaentity's name field, it's supposed to always be the entity name. Instead, you can give your entity another field, like "already_collected", and use that to record whether it has been collected. If you take the suggestion to move logic to the experience orb's step function, this becomes as easy as setting/examining self.already_collected. (You never seem to change the "collect" field of your entity - maybe this was its purpose?)
  • Usually assets like textures and sounds are also prefixed with the mod name, to prevent collisions. E.g. "experience_orb.png" instead of "orb.png"
  • Put a function for getting a player's level in your mod's table so mods using your mod do not have to depend on implementation details of your mod.

EDIT: Added more stuff (second paragraph)