Saving Player Related Data During a Game Session, How?

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

Saving Player Related Data During a Game Session, How?

by bdjnk » Mon Mar 25, 2013 01:55

I could write it out to a file, but there are two reasons I consider this a bad idea:

  1. I only need a small amount of data to persist across a single session.
  2. I want to save / update the data every time a node is placed.

I was just wondering if there were any alternatives I missed in my lengthy perusal of the forum, developer wiki, and script API source code :)

related post
how to save player data to file
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

by bdjnk » Mon Mar 25, 2013 02:01

This is the basic of what I'm attempting (very, very not done!)

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 ppos
local pname

minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
    if ppos ~= nil then
        minetest.debug("(" .. ppos.x .. "," .. ppos.y .. "," .. ppos.z .. ")")
        local directions = {
            (ppos.x == pos.x and 1 or 0),
            (ppos.y == pos.y and 1 or 0),
            (ppos.z == pos.z and 1 or 0)}

        for i = 0, # directions do
            if directions[i] == 1 then
                local npos = pos
                for j = pos[i], ppos[i] do
                    npos[i] = j
                    set_node(npos, pname)
                end
            end
        end
    end
    ppos = pos
    pname = newnode.name
end
)


The issue is that ppos and pname are always nil, when I want them (or the small table that will replace them) to persist between node placements.
Last edited by bdjnk on Mon Mar 25, 2013 02:08, edited 1 time in total.
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

by Traxie21 » Mon Mar 25, 2013 02:37

I'm on a kindle right now, so it's very hard to post code.
However, see if this is any help: https://github.com/Traxie21/ServerExtended--Unstable-

^
Navigate to the se_player_extras folder and open init.lua.
The messaging section may be something like wha you're looking for.
Last edited by Traxie21 on Mon Mar 25, 2013 02:40, edited 1 time in total.
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

by bdjnk » Mon Mar 25, 2013 05:11

Thanks kaeza and Traxie,

I was very confused, but with your help I'm now a little less muddled. The values are being saved correctly. I'm not sure why I thought they weren't.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 4 guests

cron