Working on Portals, related questions
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?
Thanks given by:
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.
Thanks given by:
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:
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
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?
Thanks given by:
Ok, seems like bug is fixed.
What it was:
Somehow using file ="/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.
Thanks given by:
Alright, it's not fixed still. For no obvious reason table with portals data corrupts. I have no idea why right now.
Thanks given by:

Users browsing this thread: 1 Guest(s)