[Mod] XP [1.0]

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

[Mod] XP [1.0]

by jordan4ibanez » Thu Oct 04, 2012 18:08

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
Last edited by jordan4ibanez on Thu Oct 04, 2012 18:09, edited 1 time in total.
If you can think it, you can make it.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu Oct 04, 2012 18:14

Yay! We are finaly Minecraft! </ironic>
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Thu Oct 04, 2012 18:47

PilzAdam wrote:Yay! We are finaly Minecraft! </ironic>


+1
Last edited by Mito551 on Thu Oct 04, 2012 18:47, edited 1 time in total.
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Thu Oct 04, 2012 19:05

PilzAdam wrote:Yay! We are finaly Minecraft! </ironic>

your game mode uses the entire minecraft texture pack, why would you even say that?
If you can think it, you can make it.
 

leo_rockway
Member
 
Posts: 131
Joined: Tue Jul 31, 2012 20:37

by leo_rockway » Fri Oct 05, 2012 01:06

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.
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Fri Oct 05, 2012 01:14

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}
If you can think it, you can make it.
 

leo_rockway
Member
 
Posts: 131
Joined: Tue Jul 31, 2012 20:37

by leo_rockway » Fri Oct 05, 2012 01:29

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.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Fri Oct 05, 2012 03:58

is there any particular usage of xp at the moment?
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Fri Oct 05, 2012 03:58

Mito551 wrote:is there any particular usage of xp at the moment?

you get rewards from it
If you can think it, you can make it.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Fri Oct 05, 2012 04:00

what kind of rewards? how do you use them. i'm not convinced

the mc lacks it as well. proper xp usage.
Last edited by Mito551 on Fri Oct 05, 2012 04:04, edited 1 time in total.
 

leo_rockway
Member
 
Posts: 131
Joined: Tue Jul 31, 2012 20:37

by leo_rockway » Fri Oct 05, 2012 07:09

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"
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Fri Oct 05, 2012 08:09

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
 

User avatar
snakevenom
Member
 
Posts: 119
Joined: Sat Sep 22, 2012 12:56

by snakevenom » Fri Oct 12, 2012 17:50

how can you assign ores to give you xp?
 

tinoesroho
Member
 
Posts: 570
Joined: Fri Feb 17, 2012 21:55

by tinoesroho » Fri Oct 12, 2012 18:00

Either a) edit init.lua or b) write a mod that redefines the defaults
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

by SegFault22 » Fri Oct 12, 2012 22:13

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.
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Sat Oct 13, 2012 01:40

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
If you can think it, you can make it.
 

Spirosxk
New member
 
Posts: 4
Joined: Sun Oct 26, 2014 10:13

Re: [Mod] XP [1.0]

by Spirosxk » Fri Nov 14, 2014 16:10

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
 

User avatar
DevilRomeoAPLUS
Member
 
Posts: 38
Joined: Sun Dec 14, 2014 10:53
In-game: DevilRomeo2

Re: [Mod] XP [1.0]

by DevilRomeoAPLUS » Tue Dec 16, 2014 15:14

Nice Mod
Bananana Banananana *Nom*
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: [Mod] XP [1.0]

by burli » Fri May 06, 2016 06:37

Is this mod not compatible with better hud and hunger? I tried it and the xp bar is not shown
 

User avatar
TailsTheFoxDoes MT
Member
 
Posts: 415
Joined: Mon Jan 18, 2016 20:50
In-game: TailsTheFox

Re: [Mod] XP [1.0]

by TailsTheFoxDoes MT » Sat May 07, 2016 18:50

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?
I'm the TailsTMM of minetest, in other words, i rock.
BRAAAAAZZZZAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!!
BTW it means TailsTheMeseMinecart, but that isn't my name, it's just a way of saying that i basically do the same thing Dantdm does but i do it with minetest And you problably can't see the invisible ink.
My mods:
My first mod:tails_boss

Mob_pack now has voice acting! Do you want YOUR VOICE included? Look in my posts for the thread!
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: [Mod] XP [1.0]

by D00Med » Sat May 14, 2016 04:09

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")
Attachments
experience(with hudbar).zip
(49.85 KiB) Downloaded 76 times
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
TailsTheFoxDoes MT
Member
 
Posts: 415
Joined: Mon Jan 18, 2016 20:50
In-game: TailsTheFox

Re: [Mod] XP [1.0]

by TailsTheFoxDoes MT » Sat May 14, 2016 07:06

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?
I'm the TailsTMM of minetest, in other words, i rock.
BRAAAAAZZZZAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!!
BTW it means TailsTheMeseMinecart, but that isn't my name, it's just a way of saying that i basically do the same thing Dantdm does but i do it with minetest And you problably can't see the invisible ink.
My mods:
My first mod:tails_boss

Mob_pack now has voice acting! Do you want YOUR VOICE included? Look in my posts for the thread!
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: [Mod] XP [1.0]

by D00Med » Sat May 14, 2016 20:41

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.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
MykieDoesStuff
Member
 
Posts: 131
Joined: Sat Aug 16, 2014 02:44
In-game: MykieDoesStuff

Re: [Mod] XP [1.0]

by MykieDoesStuff » Thu Jun 16, 2016 14:39

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?
For fast response... send me a PM
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: [Mod] XP [1.0]

by D00Med » Thu Jun 16, 2016 20:42

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
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: [Mod] XP [1.0]

by Byakuren » Thu Jun 16, 2016 21:19

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)
Every time a mod API is left undocumented, a koala dies.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron