Question for a "nil value"[solved]

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Question for a "nil value"[solved]

by azekill_DIABLO » Thu Apr 14, 2016 14:57

i'm actually doing a mod:

on_rightclick = function(self, clicker)

-- talk to the player
minetest.chat_send('BLABLABLAblaBLObla');

-- by right-clicking owner can switch Mob between follow and stand

if self.owner and self.owner == clicker:get_player_name() then


if self.order == "follow" then
self.order = "stand"
else
self.order = "follow"
end
end
end,})

i have problems with the underlined part?

In other words how to make talk a NPC on right-click?
Last edited by azekill_DIABLO on Fri Apr 15, 2016 10:57, edited 3 times in total.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
maikerumine
Member
 
Posts: 946
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: Question for a "nil value"

by maikerumine » Thu Apr 14, 2016 15:08

azekill_DIABLO wrote:i'm actually doing a mod:

on_rightclick = function(self, clicker)

-- talk to the player
minetest.chat_send('BLABLABLAblaBLObla');

-- by right-clicking owner can switch Mob between follow and stand

if self.owner and self.owner == clicker:get_player_name() then


if self.order == "follow" then
self.order = "stand"
else
self.order = "follow"
end
end
end,})

i have problems with the underlined part?


Chat part:
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_chat(clicker:getpos(),"Sam: Let's go kick some Mob butt!",3)


Add this to api:
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
         --Reese chat
         local_chat = function(pos,text,radius)
            if radius == nil then
               radius = 25
            end
            if pos ~= nil then
               local oir = minetest.get_objects_inside_radius(pos, radius)
               for _,p in pairs(oir) do
                  if p:is_player() then
                     minetest.chat_send_player(p:get_player_name(),text)
                  end
               end
            end
         end
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"

by azekill_DIABLO » Thu Apr 14, 2016 15:15

thak you for your fast awnser!!!


Edit: there is a problem, i got this error:
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
2016-04-14 17:20:39: ERROR[main]: ========== ERROR FROM LUA ===========
2016-04-14 17:20:39: ERROR[main]: Failed to load and run script from
2016-04-14 17:20:39: ERROR[main]: C:\Games\Minetest\bin\..\mods\smb\init.lua:
2016-04-14 17:20:39: ERROR[main]: C:\Games\Minetest\bin\..\mods\smb\init.lua:113: '=' expected near 'if'
2016-04-14 17:20:39: ERROR[main]: ======= END OF ERROR FROM LUA ========
2016-04-14 17:20:39: ERROR[main]: Server: Failed to load and run C:\Games\Minetest\bin\..\mods\smb\init.lua
2016-04-14 17:20:39: ERROR[main]: ModError: ModError: Failed to load and run C:\Games\Minetest\bin\..\mods\smb\init.lua
2016-04-14 17:20:39: ERROR[main]: Error from Lua:
2016-04-14 17:20:39: ERROR[main]: C:\Games\Minetest\bin\..\mods\smb\init.lua:113: '=' expected near 'if'
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
maikerumine
Member
 
Posts: 946
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: Question for a "nil value"

by maikerumine » Thu Apr 14, 2016 15:31

I would need to see full init to figure that one out. maybe your follow code is missing something, or even a misplaced comma.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"

by azekill_DIABLO » Thu Apr 14, 2016 15:41

Here is the full 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
print("Super Mario Bros mod is loading....")
print("A mod by azekill_DIABLO on an idea of MineYoshi")

mobs:register_mob("smb:toad",
{type = "npc",
passive = false,
damage = 1,
attack_type = "dogfight",
attacks_monsters = true,
pathfinding = true,
collisionbox = {-0.4, -0.4, -0.4, 0.4, 0.6, 0.4},
visual = "sprite",
textures = {
   {"toad.png"},},
blood_texture = "blood_smb.png",
makes_footstep_sound = true,
sounds = {
   random = "snap",},
view_range = 25,
walk_velocity = 3,
run_velocity = 3,
jump = true,
drops = {
   {name = "smb:toad",
   chance = 0, min = 1, max = 1},},
owner = "",
order = "follow",
water_damage = 0,
lava_damage = 5,
light_damage = 0,
fear_height = 1, 
 
on_rightclick = function(self, clicker)

   -- by right-clicking owner can switch TOAD between follow and stand
      if self.owner and self.owner == clicker:get_player_name() then

         if self.order == "follow" then
            self.order = "stand"
         else
            self.order = "follow"
         end
      end
   end,})

mobs:register_egg("smb:toad", "TOAD YOUR BEST FRIEND", "toad.png", 1)

mobs:register_mob("smb:bowser", {
type = "monster",
passive = false,
damage = 8,
attack_type = "dogshoot",
reach = 0.5,
shoot_interval = 1,
arrow = "smb:bowser_breath",
shoot_offset = 1,
hp_min = 65,
hp_max = 65,
armor = 100,
collisionbox = {-0.7, -0.8, -0.7, 0.7, 0.7, 0.7},
visual = "sprite",
textures = {
   {"bowser.png"},},
visual_size = {x=2, y=2},
blood_texture = "blood_smb.png",
makes_footstep_sound = true,
sounds = {
   random = "mobs_dungeonmaster",
   shoot_attack = "mobs_fireball",},
walk_velocity = 1,
run_velocity = 3,
jump = true,
view_range = 15,
drops = {
   {name = "default:diamondblock", chance = 0, min = 1, max = 1},},
water_damage = 1,
lava_damage = 1,
light_damage = 0,
fear_height = 3,})

mobs:register_arrow("smb:bowser_breath", {
   visual = "sprite",
   visual_size = {x = 1, y = 1},
   textures = {"bowser_breath.png"},
   velocity = 8,

   -- direct hit, no fire... only scream and horror
   hit_player = function(self, player)
      player:punch(self.object, 0.5, {
         full_punch_interval = 0.5,
         damage_groups = {fleshy = 8},
      }, nil)
   end,

   hit_mob = function(self, player)
      player:punch(self.object, 0.5, {
         full_punch_interval = 0.5,
         damage_groups = {fleshy = 8},
      }, nil)
   end,

   -- node hit, bursts into flame (not too much)
   hit_node = function(self, pos, node)
      mobs:explosion(pos, 1, 0.5, 0.5)
   end
})

mobs:register_egg("smb:bowser", "BOWSER YOUR WORST FOE", "bowser.png", 1)

--Reese chat
    local_chat = function(pos,text,radius)
  
if radius == nil then
        
radius = 25
      
end
  
if pos ~= nil then
   
local oir = minetest.get_objects_inside_radius(pos, radius)
   
for _,p in pairs(oir) do
        
if p:is_player() then
                  
minetest.chat_send_player(p:get_player_name(),text)
                
end
             
end
          
end
      
end


mobs:register_mob("smb:peach",
{type = "npc",
passive = true,
hp_min = 80,
hp_max = 80,
armor = 100,
collisionbox = {-0.3, -0.6, -0.3, 0.3, 0.3, 0.3},
visual = "sprite",
visual_size = {x=1.5, y=1.5},
textures = {
   {"peach.png"},},
blood_texture = "flower.png",
makes_footstep_sound = true,
sounds = {
   random = "snap",},
view_range = 25,
walk_velocity = 2,
run_velocity = 2,
jump = true,
drops = {
   {name = "smb:peach",
   chance = 0, min = 1, max = 1},},
water_damage = 0,
lava_damage = 0,
light_damage = 0,
fear_height = 10,

on_rightclick = function(self, clicker)
   
-- talk to the player   
   
   local_chat(clicker:getpos(),"Peach: Thank you for saving me!!!",3)
   
-- by right-clicking owner can switch PEACH between follow and stand
      if self.owner and self.owner == clicker:get_player_name() then
         if self.order == "follow" then
            self.order = "stand"   
         else
            self.order = "follow"
         end      
      end
   end,})

mobs:register_egg("smb:peach", "PEACH THE PRINCESS", "peach.png", 1)

mobs:register_mob("smb:goomba", {
type = "monster",
passive = false,
damage = 4,
attack_type = "dogfight",
reach = 1,
hp_min = 35,
hp_max = 35,
armor = 100,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "sprite",
textures = {
   {"goomba.png"},},
visual_size = {x=1.5, y=1.5},
blood_texture = "blood_smb.png",
makes_footstep_sound = true,
sounds = {
   random = "mobs_dungeonmaster",},
walk_velocity = 1,
run_velocity = 3,
jump = true,
view_range = 15,
drops = {
   {name = "default:diamond", chance = 0, min = 1, max = 1},},
water_damage = 2,
lava_damage = 10,
light_damage = 0,
fear_height = 3,})

mobs:register_egg("smb:goomba", "GOOMBA THE... GOOMBA", "goomba.png", 1)

print("The SMB mod is loaded. Have Fun!!(and get rekt by bowser)")
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
maikerumine
Member
 
Posts: 946
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: Question for a "nil value"

by maikerumine » Thu Apr 14, 2016 16:47

agg, you need to put the "reese chat" part in the api, not the init/
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"

by azekill_DIABLO » Thu Apr 14, 2016 16:50

ah ok:)

EDIT:

now i have the same error for the api.lua!THE SAME!

:) lol
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Question for a "nil value"

by TumeniNodes » Thu Apr 14, 2016 19:16

you have :
--Reese chat
local_chat = function(pos,text,radius)
if radius == nil then
radius = 25
end
if pos ~= nil then <this line need to change out ~ with =

at least I THINK that may be what is throwing the error, I could be completely wrong. If I am then full apologies
Flick?... Flick who?
 

cheapie
Member
 
Posts: 304
Joined: Mon May 14, 2012 00:59
GitHub: cheapie
IRC: cheapie
In-game: cheapie

Re: Question for a "nil value"

by cheapie » Thu Apr 14, 2016 20:03

thegreatone wrote:if pos ~= nil then <this line need to change out ~ with =

at least I THINK that may be what is throwing the error, I could be completely wrong. If I am then full apologies


There's nothing wrong with "~=". It's the opposite of "==".
 

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

Re: Question for a "nil value"

by rubenwardy » Thu Apr 14, 2016 20:15

You should indent your code properly, right now it's unreadable. At the top of the file, you should start with an indent of 0. Every time you open a function, if statement, for/while loop, or some other code block you should indent in once. Also indent in for def tables.

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
mob.register("name", {
    one = "two",
    three = "four",
    on_foo = function(player, pos)
        local pos2 = {x = pos.x, y = pos.y + 1, z = pos.z}
        minetest.chat_send_player(player:get_player_name(), "Hello!")
    end
})

function something(one, two, three)
    print(one .. " is " .. two .. " and " .. three)
end
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"

by azekill_DIABLO » Fri Apr 15, 2016 10:33

thegreatone wrote:you have :
--Reese chat
local_chat = function(pos,text,radius)
if radius == nil then
radius = 25
end
if pos ~= nil then <this line need to change out ~ with =

at least I THINK that may be what is throwing the error, I could be completely wrong. If I am then full apologies


i will try what you said :)


@cheapie : if u say it
@Rubenwardy : ok ok....
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"[solved]

by azekill_DIABLO » Fri Apr 15, 2016 10:59

that was super easy i solved it in 5 min without api.lua :)

just by adding this little function:

minetest.chat_send_player(clicker:get_player_name(), "MSG to the player")
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Question for a "nil value"

by TumeniNodes » Fri Apr 15, 2016 12:05

azekill_DIABLO wrote:
thegreatone wrote:you have :
--Reese chat
local_chat = function(pos,text,radius)
if radius == nil then
radius = 25
end
if pos ~= nil then <this line need to change out ~ with =

at least I THINK that may be what is throwing the error, I could be completely wrong. If I am then full apologies


i will try what you said :)




Unfortunately, I was mistaken. I probably should not have offered any advice as I am just learning Lua myself. I figured I would at least try to help because I know what it is like to keep getting an error and going nuts going back and forth over the code to see what is missing or misplaced, (usually has to do with a comma haha)
Anyway, glad to see you figured it out
Cheers
Flick?... Flick who?
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Question for a "nil value"[solved]

by azekill_DIABLO » Fri Apr 15, 2016 14:32

:) thank @all for your help
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron