Extra Player Info

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

Extra Player Info

by BrandonReese » Sat Mar 02, 2013 06:38

Is there a way to store extra information on the player object and retrieve it later. For instance I want to divide players up into teams and store the team name/id on on the player object for easy reference.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Sat Mar 02, 2013 07:15

you can create a table and store the player team using the name as key:

Example code:

At top of init.lua:
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
local team = { };


When player joins:
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
team[player:get_player_name()] = "red";
Last edited by kaeza on Sat Mar 02, 2013 07:16, edited 1 time in total.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Sat Mar 02, 2013 09:19

It might also work to create a new list in the player's inventory and store things in the metadata of the inventory's stacks. Player inventory is persisted automatically by the engine, so this MIGHT give you essentially a small persistent database....
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Sat Mar 02, 2013 09:46

prestidigitator wrote:It might also work to create a new list in the player's inventory and store things in the metadata of the inventory's stacks. Player inventory is persisted automatically by the engine, so this MIGHT give you essentially a small persistent database....


See this mod: https://github.com/rubenwardy/awards
the player_data table holds stuff for each player, and the function in minetest.register_onnewplayer() or whatever in trigger.lua
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Sat Mar 02, 2013 16:21

kaeza wrote:you can create a table and store the player team using the name as key:

Example code:

At top of init.lua:
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
local team = { };


When player joins:
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
team[player:get_player_name()] = "red";


I'm going to use this method. Thanks.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 9 guests

cron