get every sign in the world
#11
I don't think you should save every fence, but only those in the corners
Code:
...x++x
...+--+
x++x--+
G-----+
x+++++x
+: fence
x: fence that will be saved
Reply
Thanks given by:
#12
yeah I think that might be possible I will try it tommorow

I could edit the trace function because I already saved the move direction in it on every fence I check it would be like

if the direction is not the same save the fence
Reply
Thanks given by:
#13
ahh I remember why I didn't do that I wasn't sure how to load every fence again from the database

but I have a Idea now I could get one coordinate and try +X after that -X after that +Z after that -Z then 2 + X then 2 - X ... until I reach another point and I repeat this until I get back to the start the first coordinate. But still I would need to create ID's for gardens to do that but I think that's no Problem. or I just use the Gate as start
Reply
Thanks given by:
#14
It's not only about saving the fences, it's also about deciding whether a point is inside the garden or not, and it's gonna get ugly soon.
Reply
Thanks given by:
#15
the idea is not letting people in it it's not really necessary but I will think later about that and maybe add it as a update
Reply
Thanks given by:
#16
Ah, I completely misunderstood the protection this plugin implements, sorry. I thought it was meant to protect the complete insides of the garden.

The DB should be fast enough for any reasonably sized garden, use prepared statements and transactions to improve the speed.
Reply
Thanks given by:
#17
I think writing only the edges in the database should be enogh but how could I prepare a Database transaction?
Reply
Thanks given by:
#18
Something like this (didn't test, may need tweaking and definitely needs better error handling):
1
2
3
4
5
6
7
8
9
10
-- walls is an array-table: {{x1, y1, z1}, {x2, y2, z2}, ... }
db:exec("BEGIN TRANSACTION")  -- Postpone all DB changes into one big step, to save on disk I/O
local stmt = db:prepare("INSERT INTO GardenWalls (x, y, z) VALUES (?, ?, ?)")
for wall in ipairs(walls) do
 stmt:bind_values(unpack(wall))  -- insert "wall" values into the statement
 stmt: step()  -- execute the statement (once); the space before S should not be there (forum limit)
 stmt:reset()  -- reset the statement so that the next "wall" values can be inserted
end
stmt: finalize()
DB:exec("COMMIT")  -- Now put everything queued so far into the DB file
Reply
Thanks given by:
#19
doesn't look too complicated I will try that thanks Smile
Reply
Thanks given by:
#20
I just tried that prepare and it worked very very well xD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local db = sqlite3.open(cPluginManager:Get():GetCurrentPlugin():GetLocalFolder() .. "/storage.sqlite")
db:exec("BEGIN TRANSACTION")  -- Postpone all DB changes into one big step, to save on disk I/O
local stmt, err, errmsg = db:prepare("INSERT INTO marker (X, Y, Z, World, Player_name) VALUES (?, ?, ?, ?, ?)")
if (not stmt) then
  LOG(err .. " " .. errmsg)
end
for X in pairs(marker_temp) do
  for Y in pairs(marker_temp[X]) do
    for Z in pairs(marker_temp[X][Y]) do
      for World_name in pairs(marker_temp[X][Y][Z]) do
        for Player_name in pairs(marker_temp[X][Y][Z][World_name]) do
          LOG("Saving: " .. X .. "X " .. Y .. "Y " .. Z .. "Z " .. World_name .. " " .. Player_name)
          stmt:bind_names({X, Y, Z, World_name, Player_name})
          stmt:step()  -- execute the statement (once)
          stmt:reset()  -- reset the statement so that the next "wall" values can be inserted
        end
      end
    end
  end
end
stmt:finalize()
db:exec("COMMIT")  -- Now put everything queued so far into the DB file
marker_temp = {}
everything is now saving in a second
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)