Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tome
Tales of MajEyal
Commits
4fb23638
Commit
4fb23638
authored
7 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
moar
parent
405b3da3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!509
WIP: Orange tooltip edits
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/generator/map/MapScript.lua
+19
-4
19 additions, 4 deletions
game/engines/default/engine/generator/map/MapScript.lua
game/modules/tome/data/zones/test/mapscripts/inner_outer.lua
+5
-7
5 additions, 7 deletions
game/modules/tome/data/zones/test/mapscripts/inner_outer.lua
with
24 additions
and
11 deletions
game/engines/default/engine/generator/map/MapScript.lua
+
19
−
4
View file @
4fb23638
...
...
@@ -55,22 +55,37 @@ function _M:regenerate()
end
function
_M
:
custom
(
lev
,
old_lev
)
local
ret
=
nil
if
self
.
data
.
mapscript
then
local
file
=
self
:
getFile
(
self
.
data
.
mapscript
..
".lua"
,
"mapscripts"
)
local
f
,
err
=
loadfile
(
file
)
if
not
f
and
err
then
error
(
err
)
end
setfenv
(
f
,
setmetatable
(
env
or
{
self
=
self
,
zone
=
self
.
zone
,
level
=
self
.
level
,
lev
=
lev
,
old_lev
=
old_lev
,
Tilemap
=
require
"engine.tilemaps.Tilemap"
,
Static
=
require
"engine.tilemaps.Static"
,
WaveFunctionCollapse
=
require
"engine.tilemaps.WaveFunctionCollapse"
,
},
{
__index
=
_G
}))
return
f
()
ret
=
f
()
elseif
self
.
data
.
custom
then
ret
=
self
.
data
.
custom
(
self
,
lev
,
old_lev
)
end
if
self
.
data
.
custom
then
return
self
.
data
.
custom
(
self
,
lev
,
old_lev
)
if
ret
then
-- If we got a Tilemap instance (very likely) then ask it for the actual characters map
if
ret
.
isClassName
and
ret
:
isClassName
(
"engine.tilemaps.Tilemap"
)
then
ret
=
ret
:
getResult
(
true
)
end
return
ret
elseif
self
.
force_regen
then
return
nil
else
error
(
"Generator MapScript called without mapscript or custom fields set!"
)
end
error
(
"Generator MapScript called without customization!"
)
end
function
_M
:
generate
(
lev
,
old_lev
)
...
...
This diff is collapsed.
Click to expand it.
game/modules/tome/data/zones/test/mapscripts/inner_outer.lua
+
5
−
7
View file @
4fb23638
...
...
@@ -17,9 +17,6 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local
Tilemap
=
require
"engine.tilemaps.Tilemap"
local
Static
=
require
"engine.tilemaps.Static"
local
WaveFunctionCollapse
=
require
"engine.tilemaps.WaveFunctionCollapse"
local
merge_order
=
{
'.'
,
'_'
,
'r'
,
'+'
,
'#'
,
'O'
,
';'
,
'='
,
'T'
}
-- Water & trees layer
...
...
@@ -44,13 +41,13 @@ local wfcinner = WaveFunctionCollapse.new{
n
=
3
,
symmetry
=
8
,
periodic_out
=
false
,
periodic_in
=
false
,
has_foundation
=
false
}
-- Wait for all generators to finish
if
not
WaveFunctionCollapse
:
waitAll
(
wfcinner
,
wfcwater
,
wfcouter
)
then
print
(
"[inner_outer] a WFC failed"
)
return
self
:
regenerate
()
end
-- Load predrawn stuff
local
doorway
=
Static
.
new
(
self
:
getFile
(
"!door.tmx"
,
"samples"
))
local
doorwaytunnel
=
doorway
:
locateTile
(
'E'
,
'.'
)
-- Wait for all generators to finish
if
not
WaveFunctionCollapse
:
waitAll
(
wfcinner
,
wfcwater
,
wfcouter
)
then
print
(
"[inner_outer] a WFC failed"
)
return
self
:
regenerate
()
end
-- Merge them all
local
tm
=
Tilemap
.
new
(
self
.
mapsize
)
wfcouter
:
merge
(
1
,
1
,
wfcwater
,
merge_order
)
...
...
@@ -80,5 +77,6 @@ tm:fillAll()
-- Elimitate the rest
if
tm
:
eliminateByFloodfill
{
'#'
,
'T'
}
<
400
then
return
self
:
regenerate
()
end
-- tm:printResult()
return
tm
:
getResult
(
true
)
return
tm
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment