[Mod] Ranks and Kits [V0.3] [ranks_n_kits]

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

[Mod] Ranks and Kits [V0.3] [ranks_n_kits]

by domtron vox » Fri Mar 28, 2014 22:30

Hi, This is my first mod. I saw mcfan request a simple mod here so I obliged.

The mod is attached as both a zip and a tar.gz.

This mod adds kits, a set of items, to minetest. Each kit is related to one rank. When a player has a rank and sends the chat command /givekit he will receive all items that are in the kit. This can be repeated any number of times.

Moderators with the ranksnkits privilege can use /setrank <name> <rank> to give a rank to a connected player. Each player can only have one rank.

I have done some basic testing to make sure it works, but I am sure that it is far from foolproof.

Configuration instructions are in the README. There are also a set of planned features there under TODO that I will get to eventually. Please feel free to suggest additional features and tell me if the readme is not clear.


Licence: LGPLv3
Dependencies: none (but the example kit does use default items)
Textures: no textures


.2
-Created basic functionality
.3
-added kits folder check
-ranks are now persistent across server resets

To mods I can seem to delete the old files could you do that? I will be moving my code to github after this update.
Attachments
ranks_n_kits_V.3.zip
(2.77 KiB) Downloaded 116 times
ranks_n_kits_V.3.tar.gz
(2.37 KiB) Downloaded 94 times
ranks_n_kits.tar.gz
(2.37 KiB) Downloaded 85 times
ranks_n_kits.tar.gz
(2.27 KiB) Downloaded 95 times
ranks_n_kits.zip
(4.58 KiB) Downloaded 124 times
Last edited by domtron vox on Sun Mar 30, 2014 02:07, edited 1 time in total.
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Fri Mar 28, 2014 23:40

Thanks. I'm gonna try it now. It definitely will be nice when one keeps the rank even with restart.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 01:11

It didn't work:( I'm running 0.4.7 because 4.8 is gone. Does that make a difference?
Love MINECRAFT... will settle for Minetest
 

User avatar
CraigyDavi
Member
 
Posts: 565
Joined: Sat Aug 10, 2013 13:08
GitHub: davisonio
IRC: davisonio or CraigyDavi
In-game: davisonio or CraigyDavi

by CraigyDavi » Sat Mar 29, 2014 07:35

mcfan wrote:It didn't work:( I'm running 0.4.7 because 4.8 is gone. Does that make a difference?

What was the error?
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 11:55

It just said it failed to run /mod/kitsnranks/init.lua
Love MINECRAFT... will settle for Minetest
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Sat Mar 29, 2014 12:59

domtron vox wrote:Ranks are currently non-persistent. This means if the server is reset or the game is quit all players loose their ranks.

Perhaps ranks ought to be managed by a diffrent mod. They might be useful for other purposes.

I'm not sure how useful the mod will be. After all, if you want picks that last longer, it's easy to either make them last longer, write your own or use a mod that comes with lasting tools (the titanium mod has very durable ones).

Perhaps the mod could be intresting on creative servers: Imagine to type "/kit kitchen" and get all those homedecor kitchen furniture put into the active row of your inventory! Or "/kit bathroom". Or "/kit wool", "/kit roof", .. Could save a lot of clicks. Players could save their own kits and thus switch faster between blocks without having to rearrange half the inventory.
A list of my mods can be found here.
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 17:11

But mine isn't a creative server. This is for people who have saved ingame money and buy a rank to get a kit of stuff every 24 hours.
Love MINECRAFT... will settle for Minetest
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Sat Mar 29, 2014 21:25

Sokomine wrote:
domtron vox wrote:Ranks are currently non-persistent. This means if the server is reset or the game is quit all players loose their ranks.

Perhaps ranks ought to be managed by a diffrent mod. They might be useful for other purposes.


I was thinking something similar, but I don't know of any mods that implement ranks so maybe this mod could be expanded/split. Also I fixed the non-persistent problem(it wasn't hard) I just need to get to a decent internet connection.

Your idea does sound very useful. I could try to set something up for when creative mode is active like add all ranks to a player on join.

mcfan wrote:It didn't work:( I'm running 0.4.7 because 4.8 is gone. Does that make a difference?

I'm sorry to hear that. I have only tested it on the most recent minetest engine code since that is what I always use. Go to your minetest folder and open bin/debug.txt. Paste the contents into a code tag here so I can see what error your having.

I'll release the persistence fix once I resolve mcfan's error.
Last edited by domtron vox on Sat Mar 29, 2014 22:06, edited 1 time in total.
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 21:26

Thanks. I'll get it now.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 21:30

17:26:34: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua
17:26:34: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua
Love MINECRAFT... will settle for Minetest
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Sat Mar 29, 2014 22:03

That is not enough information I need around 10 lines. It should look like this:

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
17:45:46: ERROR[main]: ========== ERROR FROM LUA ===========
17:45:46: ERROR[main]: Failed to load and run script from
17:45:46: ERROR[main]: /home/domtron/games/minetest/bin/../games/minetest_game/mods/default/init.lua:
17:45:46: ERROR[main]: ...st/bin/../games/minetest_game/mods/default/trees.lua:1: attempt to call field 'get_content_id' (a nil value)
17:45:46: ERROR[main]: stack traceback:
17:45:46: ERROR[main]:     ...st/bin/../games/minetest_game/mods/default/trees.lua:1: in main chunk
17:45:46: ERROR[main]:     [C]: in function 'dofile'
17:45:46: ERROR[main]:     ...est/bin/../games/minetest_game/mods/default/init.lua:22: in main chunk
17:45:46: ERROR[main]: =======END OF ERROR FROM LUA ========


I checked out the 0.4.7 tag which is probably what you have mcfan and I had no errors (yes i recompiled it ;) ). Did you try it "out of the box" or did you make your own kits first? Each item needs to be on a separate line in the .kit files and follow the form "<mod name>:<item name> <optional number>". Since I don't do any checks as of yet, not doing that exactly could cause an error (It would be something like "the item 'default:wood_axe default:wood_shovel' does not exist" if you had two items on the same line).
Last edited by domtron vox on Sat Mar 29, 2014 22:06, edited 1 time in total.
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 22:36

Only those 2 lines showed up. And no, I didn't change anything till I had tested it. Could the problem be that I'm using Minitest? Every minetest mod has worked on it so far.
Love MINECRAFT... will settle for Minetest
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Sat Mar 29, 2014 22:42

I got one now. Here it is..

17:26:34: ERROR[main]: ========== ERROR FROM LUA ===========
17:26:34: ERROR[main]: Failed to load and run script from
17:26:34: ERROR[main]: /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:
17:26:34: ERROR[main]: ...e/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:88: attempt to call a nil value
17:26:34: ERROR[main]: stack traceback:
17:26:34: ERROR[main]: ...e/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:88: in main chunk
17:26:34: ERROR[main]: =======END OF ERROR FROM LUA ========
17:26:34: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua
17:26:34: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua
Last edited by mcfan on Sat Mar 29, 2014 22:42, edited 1 time in total.
Love MINECRAFT... will settle for Minetest
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Sun Mar 30, 2014 02:22

Are you sure you have the kits folder. That is the only cause of that error I can figure out. If anyone else knows of another possibility please pipe up. :)

Your ranks_n_kits mod folder should have init.lua, the kits folder, and a README.md(this one isn't necessary per say but I would prefer you keep it with the code).

I'm adding some checks to make sure the error is replaced with a relevant one that explains the problem better.

Update 0.3
-added kits folder check
-ranks are now persistent across server resets
 

User avatar
LuxAtheris
Member
 
Posts: 169
Joined: Fri Oct 25, 2013 00:54

by LuxAtheris » Sun Mar 30, 2014 02:36

Nice.
Downloaded.

EDIT:
Got this recent bug
[spoiler]
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
10:38:59: ERROR[main]: Failed to load and run script from
10:38:59: ERROR[main]: D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:
10:38:59: ERROR[main]: ...26\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:113: attempt to call field 'popon' (a nil value)
10:38:59: ERROR[main]: stack traceback:
10:38:59: ERROR[main]:     ...26\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:113: in main chunk
10:38:59: ERROR[main]: ======= END OF ERROR FROM LUA ========
10:38:59: ERROR[main]: Server: Failed to load and run D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua
10:38:59: ERROR[main]: ModError: ModError: Failed to load and run D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua
[/spoiler]
Last edited by LuxAtheris on Sun Mar 30, 2014 02:42, edited 1 time in total.
Believe you can and you’re halfway there.
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Mon Mar 31, 2014 11:49

LuxAtheris wrote:Got this recent bug
[spoiler]
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
10:38:59: ERROR[main]: Failed to load and run script from
10:38:59: ERROR[main]: D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:
10:38:59: ERROR[main]: ...26\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:113: attempt to call field 'popon' (a nil value)
10:38:59: ERROR[main]: stack traceback:
10:38:59: ERROR[main]:     ...26\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua:113: in main chunk
10:38:59: ERROR[main]: ======= END OF ERROR FROM LUA ========
10:38:59: ERROR[main]: Server: Failed to load and run D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua
10:38:59: ERROR[main]: ModError: ModError: Failed to load and run D:\minetest-0.4.9-dev20140226\bin\..\games\minetest_game\mods\ranks_n_kits\init.lua
[/spoiler]


Ok that's due to my not testing it on windows. Could you also include everything between a few lines before:

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
========== ERROR FROM LUA ===========


and what you gave me.

For some reason other people use the popon function for windows but it looks like it is just not included in the minetest lua context since it doesn't work on linux or windows(from what I can tell). Problem being I don't have minetest setup on windows so I can't test changes myself. If you know enough about how to replace some code with other code I can make some modifications and you can test them.

Replace the line

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
filenames = io.popon('dir "'..kits_dir..'"'):lines()


With

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
    os.execute('dir "'..kits_dir..'" > "'..kits_dir..'.kits"')
    local file, err = io.open(kits_dir..'.kits', 'rb')
    if not err then
         filenames = file:lines()
    end


And PM me the error you will probably get.
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Tue Apr 01, 2014 12:01

I'm trying it in Xubuntu
Love MINECRAFT... will settle for Minetest
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Tue Apr 01, 2014 14:47

mcfan wrote:I'm trying it in Xubuntu


In case your confused post 16 was directed at LuxAtheris, but this is good information to have.

mcfan wrote:I got one now. Here it is..

17:26:34: ERROR[main]: ========== ERROR FROM LUA ===========
17:26:34: ERROR[main]: Failed to load and run script from
17:26:34: ERROR[main]: /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:
17:26:34: ERROR[main]: ...e/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:88: attempt to call a nil value
17:26:34: ERROR[main]: stack traceback:
17:26:34: ERROR[main]: ...e/minetest/games/MiniTest/mods/ranks_n_kits/init.lua:88: in main chunk
17:26:34: ERROR[main]: =======END OF ERROR FROM LUA ========
17:26:34: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua
17:26:34: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/MiniTest/mods/ranks_n_kits/init.lua


This idea just occurred to me. Since the mod is in your /usr/share/<ect> directory the mod/minetest (probably) doesn't have the proper privileges to create the file there. Replace lines 76 and 77(if you still have V0.2, don't upgrade till I fix this error) in init.lua which should currently be

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
os.execute('ls "'..kits_dir..'" | grep .kit > "'..kits_dir..'.kits"')
local file, err = io.open(os.getenv('HOME')'/.kits', 'rb')


with the following code

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
os.execute('ls "'..kits_dir..'" | grep .kit > "'..os.getenv('HOME')..'/.ranksnkits-kits"')
local file, err = io.open(os.getenv('HOME')..'/.ranksnkits-kits', 'rb')


That should fix any permission errors(and not create any new ones, I hope :P).
 

User avatar
mcfan
Member
 
Posts: 120
Joined: Wed Mar 26, 2014 15:02

by mcfan » Tue Apr 01, 2014 16:39

lol - ok, ill wait for your next version.
Love MINECRAFT... will settle for Minetest
 

User avatar
domtron vox
Member
 
Posts: 106
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

by domtron vox » Tue Apr 01, 2014 19:05

mcfan wrote:lol - ok, ill wait for your next version.


Sorry for being unclear. I meant for you to go ahead and make the code substitution and If it fixes the problem I would include the code in my next update.

But on second thought I'll just make it easy for you and upload a lua script to this post. Replace your init.lua with this one. This is V0.3 so it includes player rank persistence across server start ups.
Attachments

[The extension lua has been deactivated and can no longer be displayed.]

Last edited by domtron vox on Tue Apr 01, 2014 19:06, edited 1 time in total.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 5 guests

cron