Post your modding questions here

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Wed Apr 15, 2015 17:10

So I feel like an idiot, it was really simple, I was thinking it would have to be harder than this.
This is part of the ABM
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 fuel.time <= 0 then
         print 'no fuel detected by ABM'
         local node = minetest.get_node(pos)
         print (node.name)
            if node.name == 'more_fire:campfire' then
               meta:set_string('infotext','Put more wood on the fire!')
               minetest.swap_node(pos, {name = 'more_fire:embers'})
               print 'swapped the campfire to embers'
               local timer = minetest.get_node_timer(pos)
               meta:set_string('formspec', more_fire.embers_formspec)
               timer:start(15)
            end


and then this code is part of the node.
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
   on_timer = function(pos, elapsed)
      print 'timer ended'
      local timer = minetest.get_node_timer(pos)
      timer:stop()
      minetest.set_node(pos, {name = 'more_fire:kindling'})
      end,


I'll be updating my more_fire repo on Github in about an hour, so if you want to see exactly how it all works take a look at the abms.lua lines 44-55 and the nodes.lua lines 151-175. I didn't think I could call a timer in the ABM, always learning something new.

New code is live https://github.com/NathanSalapat/more_fire
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
Ben
Member
 
Posts: 157
Joined: Tue Mar 31, 2015 20:09

Re: Post your modding questions here

by Ben » Wed Apr 15, 2015 20:20

I'd like to augment a node defined in another mod. Specifically, I want to add an 'on_use' handler to it.

I've had some success with copying the entire node description from the other mod's source code, and calling

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.register_node(':other_mod:node_name', {
    -- complete description ripped here
    on_use 
= function(itemstack, user, pointed_thing)
    end,
})

but that seems brittle and unnecessary.

I think registered nodes land in the 'minetest.registered_nodes' table, but though I can read values, any changes I make there have no effect. Is there a way to do the augmentation without this wholesale copying?
 

User avatar
Ben
Member
 
Posts: 157
Joined: Tue Mar 31, 2015 20:09

Re: Post your modding questions here

by Ben » Wed Apr 15, 2015 20:53

To answer my own question: what also works is making a shallow copy of the original table, adding my changes, and overwriting:

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 new_definition 
= {}
for 
keyvalue in pairs(minetest.registered_nodes['other_mod:node_name']) do
    
new_definition[key] = value
end
new_definition
.on_use = function … end
minetest
.register_node(':other_mod:node_name'new_definition)
 


(I had first tried modifying the registered_nodes table directly, since I was going to overwrite it anyway, but that did not work.)
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Wed Apr 15, 2015 20:55

There is, I actually just discovered it myself, from the farming mod, use 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
minetest.override_item('other_mod:node_name', {
     on_use = function(itemstack, user, pointed_thing)
     end,
})


This should do exactly what you are looking for, I've used it in two mods now, and haven't had any issues, and like I said, farming uses it for soil, and that's been around for a long time.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

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

Re: Post your modding questions here

by prestidigitator » Thu Apr 16, 2015 06:45

Yeah, minetest.override_item() seems to be designed for this purpose, actually. From lua_api.txt:

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.override_item(name, redefinition)`
    * Overrides fields of an item registered with register_node/tool/craftitem.
    * Note: Item must already be defined, (opt)depend on the mod defining it.
    * Example: `minetest.override_item("default:mese", {light_source=LIGHT_MAX})
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Fri Apr 17, 2015 00:38

With "drop =" you can set random items. Can you make it so the items drop to the ground instead of going to inventory? I know you can add minetest.item_drop to the on destruct function but can you easily add it to the drop tag?
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

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

Re: Post your modding questions here

by prestidigitator » Fri Apr 17, 2015 07:17

Don wrote:With "drop =" you can set random items. Can you make it so the items drop to the ground instead of going to inventory? I know you can add minetest.item_drop to the on destruct function but can you easily add it to the drop tag?

You can totally customize what happens using a node's on_dig() callback if you like. Or do something special from the after_dig_node() callback that doesn't use the normal drops mechanism. Or, if you mean you want to change the behavior completely for the entire game, you could either replace minetest.node_dig() to produce radically different behavior, or replace just minetest.handle_node_drops() to do something special with the items that would be dropped normally. The API documentation for that last function even states "Can be overridden to get different functionality (e.g. dropping items on ground)."
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Fri Apr 17, 2015 13:26

prestidigitator wrote:
Don wrote:With "drop =" you can set random items. Can you make it so the items drop to the ground instead of going to inventory? I know you can add minetest.item_drop to the on destruct function but can you easily add it to the drop tag?

You can totally customize what happens using a node's on_dig() callback if you like. Or do something special from the after_dig_node() callback that doesn't use the normal drops mechanism. Or, if you mean you want to change the behavior completely for the entire game, you could either replace minetest.node_dig() to produce radically different behavior, or replace just minetest.handle_node_drops() to do something special with the items that would be dropped normally. The API documentation for that last function even states "Can be overridden to get different functionality (e.g. dropping items on ground)."

The problem is I am just learning lua. the drop tag makes it easy to make it for me to add lots of items and make it drop a certain number of random items. I do not understand how to do the same with drop_item. I can use drop_item if it is one item to be dropped but to make it random items and make it choose a certain number of items from a list is where I am stuck.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Having problems figuring out how to get this code to work.

by ABJ » Fri Apr 17, 2015 14:44

So, I want to make a mod with many nodes. And I don't want to write code the traditional way because it would make me waste time and space. So, based on a solution 12Me21 found for one of my other mods, I make a noob "theory".
So this is the code I write to sample.
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 fencenames={"white","red","darkred","orange","indigo","gold","yellow","lime",}

minetest.register_node("madfences:"..fencenames, {
   tiles = {"madfences_"..fencenames..".png"},
   })

But it doesn't work! It makes the game crash on start. I've tried everything that came to my head as worth trying!
Here's the error message on debug.txt
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
Irrlicht log: Irrlicht Engine version 1.8.1
Irrlicht log: Microsoft Windows 7 Ultimate Edition Service Pack 1 (Build 7601)
Irrlicht log: Using renderer: OpenGL 2.1.2
Irrlicht log: GeForce 6150SE nForce 430/integrated/SSE2: NVIDIA Corporation
Irrlicht log: OpenGL driver version is 1.2 or better.
Irrlicht log: GLSL version: 1.2
Irrlicht log: Resizing window (800 600)
16:59:30: ERROR[main]: mod "dropper" has unsatisfied dependencies:  "nuke"
16:59:30: ERROR[main]: The following mods could not be found: "locale" "machines" "sounds" "textures" "tools"
16:59:30: WARNING: Undeclared global variable "worldedit" accessed at ...\Minetest 0.4.12\bin\..\mods\worldedit/manipulations.lua:1
16:59:30: ERROR[main]: ========== ERROR FROM LUA ===========
16:59:30: ERROR[main]: Failed to load and run script from
16:59:30: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:
16:59:30: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:3: attempt to concatenate local 'fencenames' (a table value)
16:59:30: ERROR[main]: stack traceback:
16:59:30: ERROR[main]:    D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:3: in main chunk
16:59:30: ERROR[main]: ======= END OF ERROR FROM LUA ========
16:59:30: ERROR[main]: Server: Failed to load and run D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua
16:59:30: ERROR[main]: ModError: ModError: Failed to load and run D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua

Please help me solve this error and write efficient code for mod :) I am a noob
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Having problems figuring out how to get this code to wor

by Hybrid Dog » Fri Apr 17, 2015 15:39

ABJ wrote:So, I want to make a mod with many nodes. And I don't want to write code the traditional way because it would make me waste time and space. So, based on a solution 12Me21 found for one of my other mods, I make a noob "theory".
So this is the code I write to sample.
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 fencenames={"white","red","darkred","orange","indigo","gold","yellow","lime",}

minetest.register_node("madfences:"..fencenames, {
   tiles = {"madfences_"..fencenames..".png"},
   })

But it doesn't work! It makes the game crash on start. I've tried everything that came to my head as worth trying!
Here's the error message on debug.txt
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
Irrlicht log: Irrlicht Engine version 1.8.1
Irrlicht log: Microsoft Windows 7 Ultimate Edition Service Pack 1 (Build 7601)
Irrlicht log: Using renderer: OpenGL 2.1.2
Irrlicht log: GeForce 6150SE nForce 430/integrated/SSE2: NVIDIA Corporation
Irrlicht log: OpenGL driver version is 1.2 or better.
Irrlicht log: GLSL version: 1.2
Irrlicht log: Resizing window (800 600)
16:59:30: ERROR[main]: mod "dropper" has unsatisfied dependencies:  "nuke"
16:59:30: ERROR[main]: The following mods could not be found: "locale" "machines" "sounds" "textures" "tools"
16:59:30: WARNING: Undeclared global variable "worldedit" accessed at ...\Minetest 0.4.12\bin\..\mods\worldedit/manipulations.lua:1
16:59:30: ERROR[main]: ========== ERROR FROM LUA ===========
16:59:30: ERROR[main]: Failed to load and run script from
16:59:30: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:
16:59:30: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:3: attempt to concatenate local 'fencenames' (a table value)
16:59:30: ERROR[main]: stack traceback:
16:59:30: ERROR[main]:    D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:3: in main chunk
16:59:30: ERROR[main]: ======= END OF ERROR FROM LUA ========
16:59:30: ERROR[main]: Server: Failed to load and run D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua
16:59:30: ERROR[main]: ModError: ModError: Failed to load and run D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua

Please help me solve this error and write efficient code for mod :) I am a noob

fencenames is a table, you need to use for to loop through the table
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 fencenames={"white","red","darkred","orange","indigo","gold","yellow","lime"}

for i = 1,#fencenames do
   local name = fencenames[i]
   minetest.register_node("madfences:"..name, {
      tiles = {"madfences_"..name..".png"}
   })
end
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Fri Apr 17, 2015 17:38

HELP! Hybrid Dog how do I solve this? And how do you do that small indentation?
I added some to this 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
local fencenames={"white","red","darkred","orange","indigo","gold","yellow","lime"}

for i = 1,#fencenames do
   local name = fencenames[i]
   minetest.register_node("madfences:fence_"..name, {
      tiles = {"madfences_"..name..".png"}
      drawtype = "fencelike"
   })
end

And this is what I get
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
22:33:54: ERROR[main]: ========== ERROR FROM LUA ===========
22:33:54: ERROR[main]: Failed to load and run script from
22:33:54: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:
22:33:54: ERROR[main]: D:\ABNew\Minetest 0.4.12\bin\..\mods\madfences\init.lua:7: '}' expected (to close '{' at line 5) near 'drawtype'
22:33:54: ERROR[main]: ======= END OF ERROR FROM LUA ========
 

TeTpaAka
Member
 
Posts: 131
Joined: Sat Dec 28, 2013 21:54

Re: Post your modding questions here

by TeTpaAka » Fri Apr 17, 2015 17:48

ABJ wrote:HELP! Hybrid Dog how do I solve this? And how do you do that small indentation?
I added some to this 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
local fencenames={"white","red","darkred","orange","indigo","gold","yellow","lime"}

for i = 1,#fencenames do
   local name = fencenames[i]
   minetest.register_node("madfences:fence_"..name, {
      tiles = {"madfences_"..name..".png"}
      drawtype = "fencelike"
   })
end

There is a comma missing after tiles = {"madfences_"..name..".png"}
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Fri Apr 17, 2015 18:42

Thanks for the help, both of you :) It works now.
But again I am having a problem, this time with the textures. They only render black, regardless of node. I've placed the textures in the correct folder with the correct name and it does not say error also on chat. And it shows in correct colors in inventory and wield view, just only it renders black when placed. And unlike nodes with no texture avaliable, it does not change color on log out and log in.
Can you help me with this?
Attachments
screenshot_231559384.png
screenshot_231559384.png (400.78 KiB) Viewed 3425 times
 

TeTpaAka
Member
 
Posts: 131
Joined: Sat Dec 28, 2013 21:54

Re: Post your modding questions here

by TeTpaAka » Fri Apr 17, 2015 19:09

ABJ wrote:Thanks for the help, both of you :) It works now.
But again I am having a problem, this time with the textures. They only render black, regardless of node. I've placed the textures in the correct folder with the correct name and it does not say error also on chat. And it shows in correct colors in inventory and wield view, just only it renders black when placed. And unlike nodes with no texture avaliable, it does not change color on log out and log in.
Can you help me with this?


I'm not sure. But since the code for the original fence is:
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 fence_texture = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126"
minetest.register_node("default:fence_wood", {
   description = "Wooden Fence",
   drawtype = "fencelike",
   tiles = {"default_wood.png"},
   inventory_image = fence_texture,
   wield_image = fence_texture,
   paramtype = "light",
   is_ground_content = false,
   selection_box = {
      type = "fixed",
      fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
   },
   groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
   sounds = default.node_sound_wood_defaults(),
})

You could try adding different settings. The most promising is paramtype = "light", but I really don't know.
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Fri Apr 17, 2015 19:52

Paramtype = "light" worked excellent! THX for the tip!
BTW That code looks like a whole init.lua to me :D
 

TeTpaAka
Member
 
Posts: 131
Joined: Sat Dec 28, 2013 21:54

Re: Post your modding questions here

by TeTpaAka » Fri Apr 17, 2015 20:14

ABJ wrote:BTW That code looks like a whole init.lua to me :D

It's an extract out of nodes.lua from the default mod in the Minetest Game.
And for a whole mod it is a little short. Most of the mods on the forum here are much longer.
 

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

Re: Post your modding questions here

by prestidigitator » Fri Apr 17, 2015 20:24

Don wrote:The problem is I am just learning lua. the drop tag makes it easy to make it for me to add lots of items and make it drop a certain number of random items. I do not understand how to do the same with drop_item. I can use drop_item if it is one item to be dropped but to make it random items and make it choose a certain number of items from a list is where I am stuck.

Okay. Well, the main question then is: do you want to do this for one node when it is dug, or a node at some other time, or for all nodes always everywhere in the game? The solution will be very different for different answers to that question, which is why my previous answer was rather vague.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Fri Apr 17, 2015 21:51

prestidigitator wrote:
Don wrote:The problem is I am just learning lua. the drop tag makes it easy to make it for me to add lots of items and make it drop a certain number of random items. I do not understand how to do the same with drop_item. I can use drop_item if it is one item to be dropped but to make it random items and make it choose a certain number of items from a list is where I am stuck.

Okay. Well, the main question then is: do you want to do this for one node when it is dug, or a node at some other time, or for all nodes always everywhere in the game? The solution will be very different for different answers to that question, which is why my previous answer was rather vague.

I want a few nodes placed by a mapgen I made to do it. Right now they are set up with random drops at a fixed amount. I want those drops to do item drop instead of go into inventory.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Apr 18, 2015 05:21

I'm having a problem getting this thing to radiate light. There IS no error but there is no light also.
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
for i = 1,#fencenames do
   local name = fencenames[i]
   minetest.register_node("crazyfences:glowfence_"..name, {
      description = "glowing "..fencenames[i].." fence",
      light_source = 15,
      tiles = {"crazyfences_"..name..".png"},
      drawtype = "fencelike",
      paramtype = "light",
      groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2}
})
end

Is it because different drawtypes don't emit light?
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sat Apr 18, 2015 05:25

ABJ wrote:I'm having a problem getting this thing to radiate light. There IS no error but there is no light also.
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
for i = 1,#fencenames do
   local name = fencenames[i]
   minetest.register_node("crazyfences:glowfence_"..name, {
      description = "glowing "..fencenames[i].." fence",
      light_source = 15,
      tiles = {"crazyfences_"..name..".png"},
      drawtype = "fencelike",
      paramtype = "light",
      groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2}
})
end

Is it because different drawtypes don't emit light?

try light_source = 14,
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Apr 18, 2015 05:56

THX works :) Now my fences glow
BTW how did "14" become so special here? No other number worked for me
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Post your modding questions here

by srifqi » Sat Apr 18, 2015 08:13

The light table range from 0 to 15 AFAIK. The number between that should works.
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Apr 18, 2015 09:09

How do I get this correct? I'm trying to use dyes for recipe
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
for i = 1,#fencenames do
   local name = fencename[i]
   minetest.register_craft({
      output = "crazyfences:fence_"..name,
      recipe = {{"default:fence_wood",..wool.dyes},}
})
end
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sat Apr 18, 2015 12:21

ABJ wrote:How do I get this correct? I'm trying to use dyes for recipe
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
for i = 1,#fencenames do
   local name = fencename[i]
   minetest.register_craft({
      output = "crazyfences:fence_"..name,
      recipe = {{"default:fence_wood",..wool.dyes},}
})
end

If you want to have the same colors as in the wool mod, add "wool" to the depends.txt and use this 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
for i, v in ipairs(wool.dyes) do
   minetest.register_craft({
      output = "crazyfences:fence_"..v[1],
      recipe = {"default:fence_wood", "group:dye,"..v[3]},
   })
end
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: Post your modding questions here

by ABJ » Sat Apr 18, 2015 15:30

Thanks Krock for that ;)
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sun Apr 19, 2015 16:16

fishyWET wrote:
Hybrid Dog wrote:you could use fractals for mapgen, e.g. http://en.wikipedia.org/wiki/Burning_Ship_fractal

Could you give an example of how to apply it? I'm sort of a newbie towards it.
And just to confirm, will it achieve v ?
fishyWET wrote:In simpler terms, a pre-self-defined, unchanging bare terrain that is not based on random noises.

viewtopic.php?p=176569#p176569
lt doesn't use random functions. Maybe it has something to do with accuracy of the acos function in lua.
 

Amaz
Member
 
Posts: 328
Joined: Wed May 08, 2013 08:26
GitHub: Amaz1
IRC: Amaz
In-game: Amaz

Re: Post your modding questions here

by Amaz » Mon Apr 20, 2015 21:02

Does anyone know how to make checkboxes in a formspec checked to see if they've been marked when another button in the formspec has been pressed, and not immediately?
This code always prints out Broken! when the button is pressed...
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.register_on_player_receive_fields(function(player, formname, fields)
   if formname ~= "test" then return end
   local name = player:get_player_name()
      if fields.submit then
         if fields.checkbox_one then
            minetest.chat_send_player(name, "Working!")
         else
            minetest.chat_send_player(name, "Broken!")
         end
      end
end)

And this code just gives the answer (Working!) as soon as I check the checkbox:
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.register_on_player_receive_fields(function(player, formname, fields)
   if formname ~= "test" then return end
   local name = player:get_player_name()
      if fields.rule1_false then
         minetest.chat_send_player(name, "Working!")
      else
         minetest.chat_send_player(name, "Broken!")
      end
end)

Thanks!
 

CWz
Member
 
Posts: 185
Joined: Tue Dec 24, 2013 17:01

Re: Post your modding questions here

by CWz » Thu Apr 23, 2015 09:42

does anyone have any idea what is wrong with this 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
minetest.register_chatcommand("gamemode", {
   params = "<gamemode>",
   description = "Change you gamemode ",
   privs = {gm = true},
   func = function(player, param)
      local privs = minetest.get_player_privs(player)
      if param == 0 then
         privs.fly = nil
         privs.creative = nil
      
         minetest.set_player_privs(player, privs)
         minetest.chat_send_player(player, "Notice: Game Mode updated Survival.")
         minetest.log("action", "[gamode] Player, " .. player .. " has changed game mode: Survival ")
      end
      if param == 1 then
         privs.fly = true
         privs.creative = true
         minetest.set_player_privs(player, privs)
         minetest.chat_send_player(player, "Notice: Game Mode updated to creative .")
         minetest.log("action", "[gamode] Player, " .. player .. " has changed game mode: Creative")
      end
      if param ~= 1 or param ~= 0 then
         minetest.chat_send_player(player, "Notice: Invalid gamemode .")
      end
      
   end,
})
minetest.register_privilege("gm", "Can change own gamemode")


for some reason it always returns Notice: Invalid gamemode regardless if a valid option is chosen
 

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

Re: Post your modding questions here

by rubenwardy » Thu Apr 23, 2015 09:48

Try "0" and "1" instead of 0 and 1.
 

CWz
Member
 
Posts: 185
Joined: Tue Dec 24, 2013 17:01

Re: Post your modding questions here

by CWz » Thu Apr 23, 2015 09:52

rubenwardy wrote:Try "0" and "1" instead of 0 and 1.

Thanks, also had to add "return"s
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron