Jump to content

Adding onto object id ints returning nil


Captain Cody

Recommended Posts

Title says it all, adding onto the object id integers returns nil

  
local IdAA = getElementModel(selecteda["object"]) 
if IdAA ~= 1007 
then 
local IdBB = IdAA + 1 
elseif IdAA == 1007 then 
local IdBB = IdAA + 10 
end 

local Objectbbb = createObject ( IdBB, x3,cy,cz, 0, 0, 0, true ) 

-- Debug says, expected number at argument 1, got nil --

And it seams if I remove the if statement and just do

local Objectbbb = createObject ( IdAA+1, x3,cy,cz, 0, 0, 0, true ) 

It works, but then I cannot add the 10 for the other number

Link to comment

It's your own fault:

local a = 0 
if a == 0 then 
     local a = 1 
     outputChatBox ( a )        --> outputs 1 
end  
outputChatBox ( a )      --> outputs 0 
  
  
local a = 0 
if a == 0 then 
      local b = 0 
      outputChatBox ( b )       --> 0 
else 
      local b = 1 
      outputChatBox ( b )         --> 1 
end 
outputChatBox ( b )   --> nil 

Local is only available in the same "block".

Blocks are:

file 
function 
if 
else 
elseif 
for 
while 
repeat 

An end closes the block (not in file).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...