[Modpack] NPC Framework [minetest-npcf] [WIP]

User avatar
fishyWET
Member
Posts: 162
Joined: Tue Jan 01, 2013 07:43
GitHub: neinwhal
IRC: neinwhal
In-game: neinwhal
Location: Nowhere

by fishyWET » Post

stu wrote:Can you reproduce this error? If so then please describle the steps taken to do so, thanks.
Owner set up an exhange [e.g. 1 gravel for 1 stone], and put in gravel for trading, another person tries to trade by putting in the stone and clicking accept, and this error is shown.
Last edited by fishyWET on Sat Nov 30, 2013 09:10, edited 1 time in total.

viv100
Member
Posts: 80
Joined: Sat Aug 10, 2013 16:36

by viv100 » Post

how it's done for the warriors attacking mobs like vombies

User avatar
AMMOnym
Member
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym
Location: Slovakia

by AMMOnym » Post

viv100 wrote:how it's done for the warriors attacking mobs like vombies
Mummyies: pyramids:mummy , Sandmonster: mobs:sandmonster ..... as first mod name(mobs,pyramids) and second monster name(mummy,sandmonster)
Last edited by AMMOnym on Thu Dec 05, 2013 18:29, edited 1 time in total.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

by stu » Post

fishyWET wrote:
stu wrote:Can you reproduce this error? If so then please describle the steps taken to do so, thanks.
Owner set up an exhange [e.g. 1 gravel for 1 stone], and put in gravel for trading, another person tries to trade by putting in the stone and clicking accept, and this error is shown.
Sorry about the delay, turns out this was largely caused by changes in the minetest formspec since this mod was written.
There were also a couple of other minor issues which are hopefully now resolved.
Last edited by stu on Fri Dec 06, 2013 20:17, edited 1 time in total.

Iqualfragile
Member
Posts: 160
Joined: Tue Sep 18, 2012 22:11

by Iqualfragile » Post

Is there a reason this is not implemented as an mobf mob?
Gr8 b8, m8. I rel8, str8 appreci8, and congratul8. I r8 this b8 an 8/8. Plz no h8, I'm str8 ir8. Cr8 more, can't w8. We should convers8, I won't ber8, my number is 8888888, ask for N8. No calls l8 or out of st8. If on a d8, ask K8 to loc8. Even with a full pl8, I always have time to communic8 so don't hesit8.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

by stu » Post

Iqualfragile wrote:Is there a reason this is not implemented as an mobf mob?
These are npcs not mobs, there is no good reason to add such a huge dependency.
Also, I believe mobf has it's own npcs which behave more like mobs. My npcs are aimed more at
servers (think more like the sort you find in rpg's) they have names, they have owners and persist
even after a server restart. The framework itself is extemely lightweight compared to mobf which
many servers would be reluctant install.

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

by LuxAtheris » Post

So hows the bug fixing?
Believe you can and you’re halfway there.

falsegrayburger
Member
Posts: 158
Joined: Sat Aug 03, 2013 15:16
In-game: naro

by falsegrayburger » Post

Please battler mob!
Get the goods when you win them!

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

by stu » Post

LuxAtheris wrote:So hows the bug fixing?
There are no bugs I am currently aware of, at least none that are within my control (lua wise).
Work on this mod is pretty much on hold until entities are properly fixed in minetest.
jenova99sephiros wrote:Please battler mob!
Get the goods when you win them!
For this sort of thing you should look at Simple Mobs or Mob Framework.

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

by LuxAtheris » Post

Well there is one bug where i put the npc block kinda thingy and when i try to dig it it doesnt get dug
Believe you can and you’re halfway there.

User avatar
AMMOnym
Member
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym
Location: Slovakia

by AMMOnym » Post

will be nice if u add skin chooser for npcs

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

@stu you might be interested in my g-ode interpreter code for your builder npc:

Code: Select all

reprap = {}

-- adds <material> to each node in a line from <from_position> to <to_position>
function reprap.drawline3d(from_position, to_position, material)
   --modified from https://github.com/ryanramage/bresenham3d/blob/master/index.js
   --lua port by jin_xi
   local temp
   local x0 = math.floor(from_position.x)
   local y0 = math.floor(from_position.y)
   local z0 = math.floor(from_position.z)
   local x1 = math.floor(to_position.x)
   local y1 = math.floor(to_position.y)
   local z1 = math.floor(to_position.z)
   --'steep' xy Line, make longest delta x plane
   local swap_xy = math.abs(y1 - y0) > math.abs(x1 - x0)
   if swap_xy then
      temp = x0; x0 = y0; y0 = temp --swap(x0, y0);
      temp = x1; x1 = y1; y1 = temp --swap(x1, y1);
   end
   local swap_xz = math.abs(z1 - z0) > math.abs(x1 - x0)
   if swap_xz then
      temp = x0; x0 = z0; z0 = temp --swap(x0, z0);
      temp = x1; x1 = z1; z1 = temp --swap(x1, z1);
   end
   --delta is Length in each plane
   local delta_x = math.abs(x1 - x0)
   local delta_y = math.abs(y1 - y0)
   local delta_z = math.abs(z1 - z0)
   --drift controls when to step in 'shallow' planes
   --starting value keeps Line centred
   local drift_xy = (delta_x / 2)
   local drift_xz = (delta_x / 2)
   --direction of line
   local step_x = 1
   if x0 > x1 then step_x = -1 end
   local step_y = 1
   if y0 > y1 then step_y = -1 end
   local step_z = 1
   if z0 > z1 then step_z = -1 end
   --starting point
   local y = y0
   local z = z0
   --step through longest delta (which we have swapped to x)
   local cx, cy, cz
   for x = x0, x1, step_x do
      --copy position
      cx = x; cy = y; cz = z
      --unswap (in reverse)
      if swap_xz then
                temp = cx; cx = cz; cz = temp --swap(cx, cz)
      end
      if swap_xy then
                temp = cx; cx = cy; cy = temp --swap(cx, cy)
      end
      print("drawing dot: "..cx..', '..cy..', '..cz)
      minetest.env:add_node({ x = cx, y = cy, z = cz }, { name=material, param2=2 })
      --update progress in other planes
      drift_xy = drift_xy - delta_y
      drift_xz = drift_xz - delta_z
      --step in y plane
      if drift_xy < 0 then
                y = y + step_y
                drift_xy = drift_xy + delta_x
      end
      --same in z
      if (drift_xz < 0) then
                z = z + step_z
                drift_xz = drift_xz + delta_x
      end
   end
end

-- process a gcode file <filename> placing <material> on each point touched by the machine
function reprap.process_gcode(filename, material, center)
    local path = minetest.get_modpath("reprap").."/"..filename
    local f = io.open(path)
    local line
    local cmd, param = "", ""
    local lastx, lasty, lastz
    local cmdx, cmdy, cmdz
    lastx = 0
    lasty = 0
    lastz = 0
    for line in f:lines() do
        if (line ~= "") and (line:sub(1,1) ~= ";") then
            if string.find(line, "G1 ") then
                cmdx = lastx
                cmdy = lasty
                cmdz = lastz
                for cmd, param in string.gmatch(line, "(%w)([0-9.-]+)") do
                    param = tonumber(param)
                    if cmd == "X" then
                        cmdx = param
                    elseif cmd == "Y" then
                        cmdz = param
                    elseif cmd == "Z" then
                        cmdy = param
                    end
                end
                reprap.drawline3d(
                        { x = center.x + lastx, y = center.y + lasty, z = center.z + lastz }, 
                        { x = center.x + cmdx, y = center.y + cmdy, z = center.z + cmdz }, 
                        material
                    )
                lastx = cmdx
                lasty = cmdy
                lastz = cmdz
            end
        end
    end
end

minetest.register_chatcommand("reprap", {
        params = "<gcodefilename>,<material>,<x>,<y>,<z>",
        description = "start printing a gcode file",
        privs = {},
        func = function(name, param)
            local paramlist
            print(param)
            paramlist = string.split(param, ",")
            print(paramlist[1])
            print(paramlist[2])
            print(paramlist[3])
            print(paramlist[4])
            print(paramlist[5])
            filename = paramlist[1]
            material = paramlist[2]
            drawx = tonumber(paramlist[3])
            drawy = tonumber(paramlist[4])
            drawz = tonumber(paramlist[5])
            reprap.process_gcode(filename, material, { x=drawx, y=drawy, z=drawz })
            -- reprap.process_gcode("column.gcode", "default:mese", { x=-65, y=0, z=77 })
        end
    }
)

it allows reading a gcode file, generated from cad models, like a virtul 3d printer (reprap)

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

by stu » Post

aldobr wrote:@stu you might be interested in my g-ode interpreter code for your builder npc:

Code: Select all

reprap = {}

-- adds <material> to each node in a line from <from_position> to <to_position>
function reprap.drawline3d(from_position, to_position, material)
   --modified from https://github.com/ryanramage/bresenham3d/blob/master/index.js
   --lua port by jin_xi
   local temp
   local x0 = math.floor(from_position.x)
   local y0 = math.floor(from_position.y)
   local z0 = math.floor(from_position.z)
   local x1 = math.floor(to_position.x)
   local y1 = math.floor(to_position.y)
   local z1 = math.floor(to_position.z)
   --'steep' xy Line, make longest delta x plane
   local swap_xy = math.abs(y1 - y0) > math.abs(x1 - x0)
   if swap_xy then
      temp = x0; x0 = y0; y0 = temp --swap(x0, y0);
      temp = x1; x1 = y1; y1 = temp --swap(x1, y1);
   end
   local swap_xz = math.abs(z1 - z0) > math.abs(x1 - x0)
   if swap_xz then
      temp = x0; x0 = z0; z0 = temp --swap(x0, z0);
      temp = x1; x1 = z1; z1 = temp --swap(x1, z1);
   end
   --delta is Length in each plane
   local delta_x = math.abs(x1 - x0)
   local delta_y = math.abs(y1 - y0)
   local delta_z = math.abs(z1 - z0)
   --drift controls when to step in 'shallow' planes
   --starting value keeps Line centred
   local drift_xy = (delta_x / 2)
   local drift_xz = (delta_x / 2)
   --direction of line
   local step_x = 1
   if x0 > x1 then step_x = -1 end
   local step_y = 1
   if y0 > y1 then step_y = -1 end
   local step_z = 1
   if z0 > z1 then step_z = -1 end
   --starting point
   local y = y0
   local z = z0
   --step through longest delta (which we have swapped to x)
   local cx, cy, cz
   for x = x0, x1, step_x do
      --copy position
      cx = x; cy = y; cz = z
      --unswap (in reverse)
      if swap_xz then
                temp = cx; cx = cz; cz = temp --swap(cx, cz)
      end
      if swap_xy then
                temp = cx; cx = cy; cy = temp --swap(cx, cy)
      end
      print("drawing dot: "..cx..', '..cy..', '..cz)
      minetest.env:add_node({ x = cx, y = cy, z = cz }, { name=material, param2=2 })
      --update progress in other planes
      drift_xy = drift_xy - delta_y
      drift_xz = drift_xz - delta_z
      --step in y plane
      if drift_xy < 0 then
                y = y + step_y
                drift_xy = drift_xy + delta_x
      end
      --same in z
      if (drift_xz < 0) then
                z = z + step_z
                drift_xz = drift_xz + delta_x
      end
   end
end

-- process a gcode file <filename> placing <material> on each point touched by the machine
function reprap.process_gcode(filename, material, center)
    local path = minetest.get_modpath("reprap").."/"..filename
    local f = io.open(path)
    local line
    local cmd, param = "", ""
    local lastx, lasty, lastz
    local cmdx, cmdy, cmdz
    lastx = 0
    lasty = 0
    lastz = 0
    for line in f:lines() do
        if (line ~= "") and (line:sub(1,1) ~= ";") then
            if string.find(line, "G1 ") then
                cmdx = lastx
                cmdy = lasty
                cmdz = lastz
                for cmd, param in string.gmatch(line, "(%w)([0-9.-]+)") do
                    param = tonumber(param)
                    if cmd == "X" then
                        cmdx = param
                    elseif cmd == "Y" then
                        cmdz = param
                    elseif cmd == "Z" then
                        cmdy = param
                    end
                end
                reprap.drawline3d(
                        { x = center.x + lastx, y = center.y + lasty, z = center.z + lastz }, 
                        { x = center.x + cmdx, y = center.y + cmdy, z = center.z + cmdz }, 
                        material
                    )
                lastx = cmdx
                lasty = cmdy
                lastz = cmdz
            end
        end
    end
end

minetest.register_chatcommand("reprap", {
        params = "<gcodefilename>,<material>,<x>,<y>,<z>",
        description = "start printing a gcode file",
        privs = {},
        func = function(name, param)
            local paramlist
            print(param)
            paramlist = string.split(param, ",")
            print(paramlist[1])
            print(paramlist[2])
            print(paramlist[3])
            print(paramlist[4])
            print(paramlist[5])
            filename = paramlist[1]
            material = paramlist[2]
            drawx = tonumber(paramlist[3])
            drawy = tonumber(paramlist[4])
            drawz = tonumber(paramlist[5])
            reprap.process_gcode(filename, material, { x=drawx, y=drawy, z=drawz })
            -- reprap.process_gcode("column.gcode", "default:mese", { x=-65, y=0, z=77 })
        end
    }
)

it allows reading a gcode file, generated from cad models, like a virtul 3d printer (reprap)
This is a very interenting piece of code. I actually work in mechanical engineering so I'm no stranger to gcode and cad

I will maybe try this with the builder NPC at some stage or even use it for something else, thank you for sharing it.

falsegrayburger
Member
Posts: 158
Joined: Sat Aug 03, 2013 15:16
In-game: naro

by falsegrayburger » Post

stu wrote:
LuxAtheris wrote:So hows the bug fixing?
There are no bugs I am currently aware of, at least none that are within my control (lua wise).
Work on this mod is pretty much on hold until entities are properly fixed in minetest.
jenova99sephiros wrote:Please battler mob!
Get the goods when you win them!
For this sort of thing you should look at Simple Mobs or Mob Framework.
I want to make the arena!

Josh
Member
Posts: 1146
Joined: Fri Jun 29, 2012 23:11
Location: Victoria, Australia

by Josh » Post

Look's cool, do they spawn on there own, or do you have to do it manually?
you could also make something like a butler npc that does random chores for you.

freejack
Member
Posts: 72
Joined: Wed Jan 08, 2014 06:37

by freejack » Post

This works ok, I just had an issue and now have a guard spawner that duplicates itself. I placed the spawner right clicked it and named the guard. Out pops th guard but the spawner was still there. Now if I click on it to get rid of it or pick it up it duplicates itself. Any idea how to remove it? The spawner.

falsegrayburger
Member
Posts: 158
Joined: Sat Aug 03, 2013 15:16
In-game: naro

by falsegrayburger » Post

I say things to spawn in automatic!
In addition, Spawner things random is generated in the detailed configurable automatic and Spawner want!

May not be achieved by taking you to ask this, but I would like to have when you're also Npc spawner to start in Mesecon signal!

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

CheerfulCherub wrote:Can anyone help me set up the 3d or class Characters, I download it to my mod folder and extracted and name the right name but I don't exactly know how to put the character in 3d and I tried the command for class but no luck either, I know it's not the mod it's me. Please any help in greatly appreciated. I am using 0.49minetest, love this game, making a big castle in singleplayer.

Cheerful Cherub
CheerfulCherub started a topic in the forums and posted this in it. Would anyone care to explain what needs to be done?

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

A player crashed my server using this mod. Here are the last lines before the crash:

Code: Select all

14:45:28: ACTION[ServerThread]: kinkinkijkin digs base:grass at (-389,42,207)
14:45:36: ACTION[ServerThread]: CHAT: <hoodedice> And because we have >10 players, there might be rarely any lag
14:45:44: ACTION[ServerThread]: Zen places node npcf:guard_npc_spawner at (-459,22,-97)
14:45:44: ACTION[ServerThread]: facedir: 3
14:45:49: ACTION[ServerThread]: hoodedice leaves game. List of players: Zen kinkinkijkin 
14:45:49: ERROR[main]: ServerError: .../../games/nodetopia/mods/minetest-npcf/npcf/npcf.lua:108: attempt to index local 'npc_name' (a nil value)
14:45:49: ERROR[main]: stack traceback:
14:45:49: ERROR[main]:     .../../games/nodetopia/mods/minetest-npcf/npcf/npcf.lua:108: in function 'get_valid_npc_name'
14:45:49: ERROR[main]:     .../../games/nodetopia/mods/minetest-npcf/npcf/npcf.lua:334: in function <.../../games/nodetopia/mods/minetest-npcf/npcf/npcf.lua:326>
AL lib: FreeContext: (0x2c86420) Deleting 3 Source(s)
Weird. I left the game befor the server died? LOL.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

User avatar
Esteban
Member
Posts: 873
Joined: Sun Sep 08, 2013 13:26
In-game: Esteban
Contact:

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by Esteban » Post

Stu I wonder that Is it possible to remove the name feature and checking? If so, could you please tell me what should I remove.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by stu » Post

Esteban wrote:Stu I wonder that Is it possible to remove the name feature and checking? If so, could you please tell me what should I remove.
Unfortunately the naming system is pretty fundamental to how this mod works so
I don't see an easy way it can be removed. You might be better off with sapier's mobf npcs

To be honest, I have not really worked on this for some time, it was written at
a time when my understanding of the minetest entity system (and the Lua language itself)
were a little bit naive, at best.

I have just pushed a couple of changes which should fix that bug reported in January (sorry I missed that)
and removed the duplicate entity checking as it should not be needed anymore and didn't work that well anyway.

Sokomine
Member
Posts: 4287
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by Sokomine » Post

Your npcf mod has been an inspiration and a great help when I wrote my mobf_trader mod. Especially regarding the naming system.

I'm currently facing the problem of wishing for personalized mobs (inhabitants of a village) that wander around and return to their homes at night. That may be quite difficult as it's pretty likely that only part of the village will be loaded and/or have active mobs.

[Edit] Plus the system the npcf mobs use might also work quite well for farm animals.
A list of my mods can be found here.

User avatar
Esteban
Member
Posts: 873
Joined: Sun Sep 08, 2013 13:26
In-game: Esteban
Contact:

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by Esteban » Post

stu wrote:
Unfortunately the naming system is pretty fundamental to how this mod works so
I don't see an easy way it can be removed. You might be better off with sapier's mobf npcs

To be honest, I have not really worked on this for some time, it was written at
a time when my understanding of the minetest entity system (and the Lua language itself)
were a little bit naive, at best.

I have just pushed a couple of changes which should fix that bug reported in January (sorry I missed that)
and removed the duplicate entity checking as it should not be needed anymore and didn't work that well anyway.
Thanks for your reply!

User avatar
SAMIAMNOT
Member
Posts: 416
Joined: Wed Sep 03, 2014 00:51
In-game: notanewbie
Location: Desert

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by SAMIAMNOT » Post

Looks great, cant wait to get it, got a few questions:
1) Is this thing still in development? (Not that it matters unless it's deleted online)
2) Can you please make female deco NPCs? And make it so that if a male NPC touches a Female NPC a child NPC.
3) Do NPCs spawn by themselves? I had trouble getting stuff to spawn with Animals Modpack.
I test mines.

User avatar
SAMIAMNOT
Member
Posts: 416
Joined: Wed Sep 03, 2014 00:51
In-game: notanewbie
Location: Desert

Re: [Modpack] NPC Framework [minetest-npcf] [WIP]

by SAMIAMNOT » Post

Good Work. Nice mod.
My brother said a trader was going to give him like 20 peices of wood for like 5 obsidian. ;) Hey, there are unfair traders today! (Just not in the US. Here they call it being overpriced.)
*EDIT* Also my lil bro claims that if you place an NPC it may crash Minetest.
I test mines.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests