Working on Portals, related questions
#41
Can I have cWorld::ForEachChunkInRect() exported in Lua? This seems to be a good thing for plugins optimisation... And this will shrink lua code ammountBig Grin Since it's already there, won't be a big deal, right?
Reply
Thanks given by:
#42
Well that one is a bit more involved, since it is using a multi-callback - one callback for coords, one for heightmap, another for biome map, blocktypes, blockmeta, ... Have a look at cChunkDataCallback in ChunkDef.h. Now I don't know how to make that Lua-accessible easily - should the function take a gazillion arguments, one for each callback function? Or a Lua object with functions assigned to it for each callback? Also, my Lua hacking skills are not up to this megatask.
Reply
Thanks given by:
#43
Wonderful. I updated from r856 (yeah, it's been a while) to r1017. Guess what? Portals are broken. And I have NO IDEA why, because this code:
Code:
Player:SendMessage("SOME YOUR PORTAL STATE BELONG TO US! "..PlayersData[_name].portal_state)
if (PlayersData[_name].portal_state == -1) then
    Player:SendMessage("ALL YOUR PORTAL STATE BELONG TO US! "..PlayersData[_name].portal_state)
    Player:SendMessage("Stand still for "..PORTAL_ACTIVATION_TIME.." seconds for teleportation")
    PlayersData[_name].portal_state = 1
end
result is in-game chat message with "SOME YOUR PORTAL STATE BELONG TO US! -1", and nothing else happens (teleportation and two more messages should!).
So, somehow if (PlayersData[_name].portal_state == -1) then is not a valid statement. Although it is. As it should be. But it isn't.
Using == "-1" helped, but make whole code somewhat messy. tonumber() had no effect.

Any ideas on why the f*ck did it happened?
Reply
Thanks given by:
#44
Ok, seems like bug is fixed.
What it was:
Somehow using file = io.open(PLUGIN:GetLocalDirectory().."/portals_portals.dat", "w+") with "w+" mode caused data to be corrupted upon re-writing. Using just "w" mode works just fine (or, at least, seems to be fine at first test).

I'll do some more my lua magic and then will upload updated version, I guess. In case anyone suffers the bug and needs it immediately I can provide quick-fixed version.
Reply
Thanks given by:
#45
Alright, it's not fixed still. For no obvious reason table with portals data corrupts. I have no idea why right now.
Reply
Thanks given by:




Users browsing this thread: 11 Guest(s)