android
Prev Previous Post   Next Post Next
  #1  
Old 12-14-2011, 08:58 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Exclamation Table assigning-Bug

After many tries to fix a bug I have encountered, and much research, I am no closer to solving this bug then when I started. So I was wondering if anyone had any ideas on how to fix it.

In Pingus, we use two tables, to map our the penguins actions ( one for left movement, and one for right movement). What we do is, compute the penguin's action at a certian pixel ( falling, moving, climbing a hill, turning, ect) and save that result to a table with a indices of the x and y coordinate ( we have tried several ways to write the indices, ranging from strings to numbers). Then if a penguin reaches a coordinates that has already been encountered, we just grab the end result from the table.

The problem starts when we attempt to use abilities such as the digger or miner(we have also re-routed the ability's code to use the walker's code which has not crashed yet, but it still crashes). If we try to assign a value to a table (ie: record_table[tostring(p.x) .. "_xpos" .. tostring(p.y) .. "_ypos"] = "falling") or reading from the table (ie: if record_table[corrdiante_string] == nil) then the player will crash, with the error: "attempt to call a nil value". The game also doesnt crash for every coordinate, so the digger will work for a random amount of time, then that error occurs.

here is a basic sample of the code we use:
Code:
function memoize_collision_right(x,y,p,ability_effect_value)
    local new_value = tostring(x) .. "00" .. tostring(y)
    new_value = tonumber(new_value)
    if memoize_collision_right_dat[new_value] == nil and p.state ~= "climbing" and p.type ~= "builder" then
        if ability_effect_value ~= nil then
            table.insert(memoize_collision_right_dat,new_value,ability_effect_value)
        else
            table.insert(memoize_collision_right_dat,new_value,engine.collision(p))
        end
    elseif p.state == "climbing" then
        engine.collision(p)
    end
    return memoize_collision_right_dat[new_value]
end
Note: our first try was to use table.insert instead of just writing memoize_collision_right_dat[new_value] = "falling" , but that did not help either. And this bug does not exist on the simulator.

Does anyone have a solution or know why this would happen, our entire project hangs on this bug.

Thanks,

Jbob & Redwolfhome
Reply With Quote

Advertisement [Remove Advertisement]

 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:29 AM.