Post your modding questions here

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Mar 12, 2016 08:58

It doesn't work:
Code: Select all
local function getb(d)
   return math.log(2*d) / (1 - d)
end

local function geta(b)
   return 1/(1-math.exp(-b))
end

local function v(d)
   print("d = " .. d)
   local b = getb(d)
   print("b = " .. b)
   local a = geta(b)
   print("a = " .. a)
   -- col should be 0.5
   local col = a*(1-math.exp(-b*d))
   print("col = " .. col)
   return col
end

for i = 0,10 do
   v(i/10)
   print("\r")
end

+ "col should be 0.5 because v(d) should be 0.5"

deriving is a nice idea but
call the left side l(b) and the right side r(b)
l(b) = r(b)
the derivation gives the pitch of the function, but l and r are just equal at b, which is fixed, so l'(b) doesn't need to be r'(b)

Maybe you need to use the W function to shift it for b

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Mar 12, 2016 09:29

l made it get b approximately:
Code: Select all
local function geta(b)
   return 1/(1-math.exp(-b))
end

local minb = -1002
local maxb = 30001

local function v(d)
   local b
   io.write("d = " .. d.."\n")
   for i = 0,100 do
      b = (minb+maxb)/2
      io.write("b = " .. b.."; ")
      local a = geta(b)
      --print("a = " .. a)
      local col = a*(1-math.exp(-b*d))
      io.write("col = " .. col.."\n")

      if math.log(col-0.5)/math.log(10) < -9
      or tostring(col) == "nan" then
         break
      elseif col < 0.5 then
         minb = b
      else
         maxb = b
      end
   end
end

v(0.8)

+ "the result"


This makes a list of bs:
Code: Select all
local function geta(b)
   return 1/(1-math.exp(-b))
end

local function v(d)
   local minb = -1002
   local maxb = 30001

   local b
   --io.write("d = " .. d.."\n")
   for i = 0,100 do
      b = (minb+maxb)/2
      --io.write("b = " .. b.."; ")
      local a = geta(b)
      --print("a = " .. a)
      local col = a*(1-math.exp(-b*d))
      --io.write("col = " .. col.."\n")

      if math.log(col-0.5)/math.log(10) < -9
      or tostring(col) == "nan" then
         break
      elseif col < 0.5 then
         minb = b
      else
         maxb = b
      end
   end
   return b
end

for i = 0,10 do
   local d = i/10
   io.write("d = " .. d..";"..(" "):rep(5-#tostring(d)).."b = "..v(d).."\n")
end

To use it for automatic brightness adjusting, the bs can be stored in a table and to get a b, interpolation can be used
Code: Select all
d = 0;    b = 30001
d = 0.1;  b = 6.921614307927
d = 0.2;  b = 3.2812798977898
d = 0.3;  b = 1.8010717819961
d = 0.4;  b = 0.82216324127785
d = 0.5;  b = 9.4905772130005e-09
d = 0.6;  b = -0.82216322934596
d = 0.7;  b = -1.8010717700643
d = 0.8;  b = -3.2812798929072
d = 0.9;  b = -6.9216142889459
d = 1;    b = -759.7890625

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Mar 12, 2016 09:44

Code: Select all
-- code including much unused

local load_time_start = os.clock()
math.randomseed(os.time()+tonumber(io.popen("date +%N"):read("*all")))

--$ luajit parab.lua | pnmtopng > dsa.png && optipng -o7 -quiet dsa.png
local s = 2^10
local col = 255

local tab = {"P3", s, s, col}
local num = 5

local function info(msg)
   os.execute("notify-send '"..msg.."'")
end

local function round(n)
   return math.floor(n+0.5)
end

local function gcol(c)
   if c == math.huge
   or tostring(c) == "-nan" then
      c = 0
   end
   return round(c)%(col+1)
end

local function set(r,g,b)
   tab[num] = gcol(r)
   tab[num+1] = gcol(g)
   tab[num+2] = gcol(b)
   num = num+3
end

local sts = {}
local minc, maxc
local function tset(c)
   if not minc then
      minc = c
      maxc = c
   end
   minc = math.min(c, minc)
   maxc = math.max(c, maxc)
   table.insert(sts, c)
end


local function geta(b)
   return 1/(1-math.exp(-b))
end

local function v(d)
   local minb = -1002
   local maxb = 30001

   local b
   --io.write("d = " .. d.."\n")
   for i = 0,100 do
      b = (minb+maxb)/2
      --io.write("b = " .. b.."; ")
      local a = geta(b)
      --print("a = " .. a)
      local col = a*(1-math.exp(-b*d))
      --io.write("col = " .. col.."\n")

      if math.log(col-0.5)/math.log(10) < -9
      or tostring(col) == "nan" then
         break
      elseif col < 0.5 then
         minb = b
      else
         maxb = b
      end
   end
   return b
end

local function f(x)
   return v((x+s/2)/s)*s/100--math.sqrt(math.abs(10000-x*x))
end


local crds = {}
local a,b = -s/2+1, s/2
for x = a,b do
   if x == 0 then
      for y = a,b do
         crds[y] = crds[y] or {}
         crds[y][x] = 0.5
      end
   else
      local yf = f(x)
      if yf > b then
         for y = a,b do
            crds[y] = crds[y] or {}
            crds[y][x] = 0
         end
      elseif yf < a then
         for y = a,b do
            crds[y] = crds[y] or {}
            crds[y][x] = 1
         end
      else
         for y = a,math.floor(yf) do
            crds[y] = crds[y] or {}
            crds[y][x] = 0
         end
         for y = math.ceil(yf),b do
            crds[y] = crds[y] or {}
            crds[y][x] = 1
         end
         local y = math.ceil(yf)
         crds[y] = crds[y] or {}
         crds[y][x] = math.max(0, math.min(1, y-yf))
      end
   end
end

-- [[
for y = s/2,-s/2+1,-1 do
   for x = 1,s do
      x = x-s/2
      tset(crds[y][x])
   end
end--]]
--[[
for x = 1,s do
   x = x-1--s/2
   tset(do_ws_func(2, x))
end--]]


--[[
local crn = {x1=0,y1=0, x2=0,y2=0}
local hs = {}
local function seth(x,y)
   if not hs[y] then
      hs[y] = {}
   end
   if not hs[y][x] then
      hs[y][x] = 1
   else
      hs[y][x] = hs[y][x]+1
   end
   crn.x1 = math.min(x, crn.x1)
   crn.y1 = math.min(y, crn.y1)
   crn.x2 = math.max(x, crn.x2)
   crn.y2 = math.max(y, crn.y2)
end

local function geth(x,y)
   if not hs[y] then
      return 0
   end
   return hs[y][x] or 0
end

local cx = 0
local cy = 0
local dirs = {
   {1,0},
   {0,1},
   {-1,0},
   {0,-1},
}

local dif = maxc-minc
for i = 1,#sts do
   local v = sts[i]
   v = (v-minc)/dif
   sts[i] = v
   -- [ [
   v = v*255
   v = v*math.pi
   set(v,v,v)-- ] ]

   seth(cx,cy)
   --info(round(v*3)+1)
   --local dir = (v*300)%1
   local dir = (round(v*math.pi*100))%4+1
   local ndir = dirs[dir]
   cx = cx+ndir[1]
   cy = cy+ndir[2]
end

crn.x1 = crn.x1-5
crn.y1 = crn.y1-5
crn.x2 = crn.x2+5
crn.y2 = crn.y2+5

local s = {crn.x2-crn.x1, crn.y2-crn.y1}
tab[2] = s[1]+1
tab[3] = s[2]+1

maxc = 0
for y,xs in pairs(hs) do
   for _,h in pairs(xs) do
      maxc = math.max(maxc, h)
   end
end

for y = crn.y1,crn.y2 do
   for x = crn.x1,crn.x2 do
      local c = 0
      local v = hs[y]
      if v then
         c = hs[y][x] or 0
      end
      c = c*255/maxc
      --c = c%2*255
      set(c,c,c)
   end
end--]]

local dif = maxc-minc
for i = 1,#sts do
   local v = sts[i]
   v = (v-minc)/dif
   --sts[i] = v
   -- [[
   v = v*255
   --v = v*math.pi
   set(v,v,v)--]]

   --[[
   seth(cx,cy)
   --info(round(v*3)+1)
   --local dir = (v*300)%1
   local dir = (round(v*math.pi*100))%4+1
   local ndir = dirs[dir]
   cx = cx+ndir[1]
   cy = cy+ndir[2]--]]
end

info("fi")

print(table.concat(tab, " "))

local time = math.floor(tonumber(os.clock()-load_time_start)*100+0.5)/100
local msg = "fertig nach ca. "..time.."s"
if time > 0.05 then
   info(msg)
end

l think 1 y is 50 x on the picture
Image
Attachments
dsa.png
(4.94 KiB) Not downloaded yet

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
Location: Brasil - ES
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Sat Mar 12, 2016 19:10

Well, nice results for your approximation :D

I just had this idea cause the (-1) was pissing me off after a while trying shift the equation hehe and d/dx(constant) = 0, a perfect murder hehe, unfortunately doesn't work in this case.

I just learned Calculus I (limits, derivatives and integrals, with just one variable and at IR) and I need more practice, but I'll try understand W function in somewhere else.
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sun Mar 13, 2016 08:46

l didn't know derivations with more than one variable are possible.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
Location: Brasil - ES
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Sun Mar 13, 2016 13:08

partial derivatives of functions that have more than one variable.
https://en.wikipedia.org/wiki/Partial_derivative
And derivatives of vectors, I see that like "more than one variable" (in this case axis), gradient and others operations
https://en.wikipedia.org/wiki/Gradient

the point is I'm just getting started at this new stage of mathematics :P
This is probably getting off-topic it's better we finish it here.
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4

Re: Post your modding questions here

by Foghrye4 » Sun Mar 13, 2016 18:52

I have a question!
I want to override ore generation of other mods. Thus i can use "minetest.clear_registered_ores()". But how i can control mod load order? Does it depends from mod name?
 

User avatar
paramat
Developer
 
Posts: 3528
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: Post your modding questions here

by paramat » Mon Mar 14, 2016 09:06

the 'depends.txt' file controls mod order.
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Mar 14, 2016 16:36

Do mesh objects have a cuboid collision box or a complex one?

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

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

Re: Post your modding questions here

by Don » Mon Mar 14, 2016 17:02

You set the collision box like a nodebox.
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
 

User avatar
xeranas
Member
 
Posts: 155
Joined: Fri Feb 05, 2016 11:06

Re: Post your modding questions here

by xeranas » Tue Mar 15, 2016 06:43

Hi,
I'm trying to create block similar to furnace but more like "item converter". Due this reason I cannot use regular "fuel" recipes (I want that items as "fuel" would work only on my block).

So far I decided go ABM route which would check item in "fuel" slot and add it as fuel time manually according some predefined rules. To do so I need "extract" fuel name from fuel slot (it will be multiple custom "fuels").

I take furnace as example
Code: Select all
minetest.register_abm({
  action = function(pos, node, active_object_count, active_object_count_wider)
    local meta = minetest.get_meta(pos)
    local inv = meta:get_inventory()
    local fuellist = inv:get_list("fuel")

Seems I getting list of userdata objects. I do not know how to extract properties from them rather than guessing. Unfortunately minetest dev wiki and lua api documentation does not provide explanation about userdata (or I missed?).
Code: Select all
{ <userdata 1> }

Maybe I did completely wrong and I need go another direction?
 

User avatar
xeranas
Member
 
Posts: 155
Joined: Fri Feb 05, 2016 11:06

Re: Post your modding questions here

by xeranas » Tue Mar 15, 2016 06:51

guessing over
Code: Select all
userdata:get_name()

Still where I could find which properties I can get from userdata? Maybe we can add some notes in dev wiki or lua api to help newbies like me?
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Tue Mar 15, 2016 16:47

They are a list of ItemStack. You can find the methods available in the mod API doc.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
xeranas
Member
 
Posts: 155
Joined: Fri Feb 05, 2016 11:06

Re: Post your modding questions here

by xeranas » Wed Mar 16, 2016 05:40

Byakuren wrote:They are a list of ItemStack. You can find the methods available in the mod API doc.

Thanks!, I was bit confused because lua.api documentation does not explicity says which type of objects from list I should expect. InvRef get_list
get_list(listname): return full list
 

User avatar
garywhite
Member
 
Posts: 109
Joined: Fri Feb 12, 2016 16:19
Location: San Francisco, CA
GitHub: garywhite207
IRC: same as MT name
In-game: garywhite garywhite1

Re: Post your modding questions here

by garywhite » Thu Mar 17, 2016 17:49

I am trying to set up a server, but I cannot get unified_inventory to work. Attached is the in-game load error.

Here is what debug says:
Code: Select all
2016-03-17 10:44:46: ERROR[main]: Failed to load and run script from
2016-03-17 10:44:46: ERROR[main]: D:\FlipShare Data\mt\minetest-0.4.13\bin\..\mods\unifiedinventory\init.lua:
2016-03-17 10:44:46: ERROR[main]: ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:60: Name unified_inventory:bag_small does not follow naming conventions: "modname:" or ":" prefix required
2016-03-17 10:44:46: ERROR[main]: stack traceback:
2016-03-17 10:44:46: ERROR[main]:    [C]: in function 'error'


Does anyone know? I tried installing bags mod, to no avail. Please reply.

garywhite
mt error.png
(59.14 KiB) Not downloaded yet

Code: Select all
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:60: in function 'check_modname_prefix'
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:98: in function 'register_item'
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:216: in function 'really_register_tool'
2016-03-17 10:44:46: ERROR[main]:    ...t-0.4.13\bin\..\mods\Technic\technic_worldgen/crafts.lua:162: in function 'register_tool'
2016-03-17 10:44:46: ERROR[main]:    ...mt\minetest-0.4.13\bin\..\mods\unifiedinventory/bags.lua:173: in main chunk
2016-03-17 10:44:46: ERROR[main]:    [C]: in function 'dofile'
2016-03-17 10:44:46: ERROR[main]:    ...mt\minetest-0.4.13\bin\..\mods\unifiedinventory\init.lua:63: in main chunk
2016-03-17 10:44:46: ERROR[main]: ======= END OF ERROR FROM LUA ========
2016-03-17 10:44:46: ERROR[main]: Server: Failed to load and run D:\FlipShare Data\mt\minetest-0.4.13\bin\..\mods\unifiedinventory\init.lua
2016-03-17 10:44:46: ERROR[main]: ModError: ModError: Failed to load and run D:\FlipShare Data\mt\minetest-0.4.13\bin\..\mods\unifiedinventory\init.lua
2016-03-17 10:44:46: ERROR[main]: Error from Lua:
2016-03-17 10:44:46: ERROR[main]: ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:60: Name unified_inventory:bag_small does not follow naming conventions: "modname:" or ":" prefix required
2016-03-17 10:44:46: ERROR[main]: stack traceback:
2016-03-17 10:44:46: ERROR[main]:    [C]: in function 'error'
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:60: in function 'check_modname_prefix'
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:98: in function 'register_item'
2016-03-17 10:44:46: ERROR[main]:    ...Data\mt\minetest-0.4.13\bin\..\builtin\game\register.lua:216: in function 'really_register_tool'
2016-03-17 10:44:46: ERROR[main]:    ...t-0.4.13\bin\..\mods\Technic\technic_worldgen/crafts.lua:162: in function 'register_tool'
2016-03-17 10:44:46: ERROR[main]:    ...mt\minetest-0.4.13\bin\..\mods\unifiedinventory/bags.lua:173: in main chunk
2016-03-17 10:44:46: ERROR[main]:    [C]: in function 'dofile'
2016-03-17 10:44:46: ERROR[main]:    ...mt\minetest-0.4.13\bin\..\mods\unifiedinventory\init.lua:63: in main chunk
2016-03-17 10:44:46: ERROR[main]: Check debug.txt for details.
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Thu Mar 17, 2016 17:53

you called the mod folder unifiedinventory, but you need to call it unified_inventory

"read before asking for help"
http://wiki.minetest.net/Troubleshootin ... a.E2.80.9D

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
BrunoMine
Member
 
Posts: 1064
Joined: Thu Apr 25, 2013 17:29
Location: SP-Brasil
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Thu Mar 17, 2016 20:00

About the method:
Code: Select all
minetest.register_decoration()

How I can set a quantity of generated items?
 

User avatar
MineYoshi
Member
 
Posts: 5372
Joined: Wed Jul 08, 2015 13:20

Re: Post your modding questions here

by MineYoshi » Tue Mar 22, 2016 22:50

Exactly how i can stop this function with other use?

Code: Select all
minetest.register_tool("headphones:1headphones", {
   description = "Headphones Test Song",
   inventory_image = "testh.bmp",

   on_use = function()
      minetest.sound_play("test")
   end,
   
      
})


I mean i click one time, plays the sound, i click other time, the song plays again with the other.
I want to do this, i click one time, plays the sound, i click again and the stops the sound, how i do that?
Happy new Year 2020: let's all aim finally for a clear vision of what we want to make of Minetest!
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
Location: Brasil - ES
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Wed Mar 23, 2016 00:58

MineYoshi wrote:Exactly how i can stop this function with other use?

Code: Select all
minetest.register_tool("headphones:1headphones", {
   description = "Headphones Test Song",
   inventory_image = "testh.bmp",

   on_use = function()
      minetest.sound_play("test")
   end,
   
      
})


I mean i click one time, plays the sound, i click other time, the song plays again with the other.
I want to do this, i click one time, plays the sound, i click again and the stops the sound, how i do that?

What if you:
Code: Select all
--Put a global var here
sound = 'no'
minetest.register_tool("headphones:1headphones", {
   description = "Headphones Test Song",
   inventory_image = "testh.bmp",

   on_use = function()
        if sound == 'no' then
            sound = minetest.sound_play("test") --keep the "reference" of the sound
        else
            minestes.sound_stop(sound)
           sound = 'no'
       end
   end,
   
      
})
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Wed Mar 23, 2016 07:53

Except you probably want to make sound a local var instead.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
rubenwardy
Moderator
 
Posts: 5948
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Wed Mar 23, 2016 10:16

You should rarely use global variables as they will be present in other mods. You should only create global variables with the same name as your mod.
 

User avatar
Hybrid Dog
Member
 
Posts: 2721
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Wed Mar 23, 2016 10:48

VaE adds a vector.dot and people may think it's added by builtin, so they don't notice that their mod crashes if pipeworks isn't installed

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
Location: Brasil - ES
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Wed Mar 23, 2016 13:11

rubenwardy wrote:You should rarely use global variables as they will be present in other mods. You should only create global variables with the same name as your mod.


hmm This is a convention ? I understand the fact, avoid using global vars, because they can conflict with other mods but if I use something like that, would it be ok?:
nameofmymod_sound = 'no'
or local sound = 'no' also works inside the func?

another Q: This is documented on wiki or on somewhere?, I'm just can't remember...
That was just a "speed coding"...
Reading this I think I should review some code on my mods... XD
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
rubenwardy
Moderator
 
Posts: 5948
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Wed Mar 23, 2016 14:06

It's just good practice not to. Instead of nameofmymod_sound you should do nameofmymod.sound or a local variable.
Global variables are the best way to communicate between files. The alternative is passing parameters between files is a bit weird.

Code: Select all
-- You can do this if you want want to make a global variable,
-- but I usually use nameofmod.sound as I prefer that personally.
local sound = "no"
dofile(minetest.get_modpath() .. "/other.lua", sound)


This doesn't seem to be mentioned anyway, except a little bit by me here: http://rubenwardy.com/minetest_modding_ ... and-global
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: Google [Bot] and 1 guest