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
3a66e4b7
There was a problem fetching the pipeline summary.
Commit
3a66e4b7
authored
4 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
chat conditions can all be not'ed
parent
87964a30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game/engines/default/engine/Chat.lua
+18
-17
18 additions, 17 deletions
game/engines/default/engine/Chat.lua
with
18 additions
and
17 deletions
game/engines/default/engine/Chat.lua
+
18
−
17
View file @
3a66e4b7
...
...
@@ -99,7 +99,7 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
end
end
local
function
add_action
(
action
)
local
function
add_action
(
node
,
action
)
self
:
setFunctionEnv
(
action
)
if
answer
.
action
then
local
old
=
answer
.
action
...
...
@@ -112,7 +112,8 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
answer
.
action
=
action
end
end
local
function
add_cond
(
cond
)
local
function
add_cond
(
node
,
cond
)
if
node
.
data
[
'not'
]
then
local
oc
=
cond
cond
=
function
(
npc
,
player
)
return
not
oc
(
npc
,
player
)
end
end
self
:
setFunctionEnv
(
cond
)
if
answer
.
cond
then
local
old
=
answer
.
cond
...
...
@@ -132,7 +133,7 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
local
action
,
err
=
loadstring
(
"return function(npc, player) "
..
node
.
data
.
code
..
" end"
)
if
not
action
and
err
then
error
(
"[Chat] chatFormatActions ERROR: "
..
err
)
end
action
=
action
()
add_action
(
action
)
add_action
(
node
,
action
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"lua-cond"
then
...
...
@@ -140,38 +141,38 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
local
cond
,
err
=
loadstring
(
"return function(npc, player) "
..
node
.
data
.
code
..
" end"
)
if
not
cond
and
err
then
error
(
"[Chat] chatFormatActions ERROR: "
..
err
)
end
cond
=
cond
()
add_cond
(
cond
)
add_cond
(
node
,
cond
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"quest-set"
then
local
Quest
=
require
"engine.Quest"
local
sub
=
nil
if
node
.
data
.
sub
~=
""
then
sub
=
node
.
data
.
sub
end
add_action
(
function
(
npc
,
player
)
if
player
:
hasQuest
(
node
.
data
.
quest
)
then
player
:
setQuestStatus
(
node
.
data
.
quest
,
Quest
[
node
.
data
.
status
],
sub
)
end
end
)
add_action
(
node
,
function
(
npc
,
player
)
if
player
:
hasQuest
(
node
.
data
.
quest
)
then
player
:
setQuestStatus
(
node
.
data
.
quest
,
Quest
[
node
.
data
.
status
],
sub
)
end
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"quest-give"
then
local
Quest
=
require
"engine.Quest"
add_action
(
function
(
npc
,
player
)
player
:
grantQuest
(
node
.
data
.
quest
)
end
)
add_action
(
node
,
function
(
npc
,
player
)
player
:
grantQuest
(
node
.
data
.
quest
)
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"quest-cond"
then
local
Quest
=
require
"engine.Quest"
local
sub
=
nil
if
node
.
data
.
sub
~=
""
then
sub
=
node
.
data
.
sub
end
add_cond
(
function
(
npc
,
player
)
return
player
:
hasQuest
(
node
.
data
.
quest
)
and
player
:
isQuestStatus
(
node
.
data
.
quest
,
Quest
[
node
.
data
.
status
],
sub
)
end
)
add_cond
(
node
,
function
(
npc
,
player
)
return
player
:
hasQuest
(
node
.
data
.
quest
)
and
player
:
isQuestStatus
(
node
.
data
.
quest
,
Quest
[
node
.
data
.
status
],
sub
)
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"quest-has"
then
if
node
.
data
.
state
==
"has"
then
add_cond
(
function
(
npc
,
player
)
return
player
:
hasQuest
(
node
.
data
.
quest
)
end
)
add_cond
(
node
,
function
(
npc
,
player
)
return
player
:
hasQuest
(
node
.
data
.
quest
)
end
)
else
add_cond
(
function
(
npc
,
player
)
return
not
player
:
hasQuest
(
node
.
data
.
quest
)
end
)
add_cond
(
node
,
function
(
npc
,
player
)
return
not
player
:
hasQuest
(
node
.
data
.
quest
)
end
)
end
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"object-has"
then
add_cond
(
function
(
npc
,
player
)
add_cond
(
node
,
function
(
npc
,
player
)
local
actor
=
node
.
data
.
who
==
"player"
and
player
or
npc
if
node
.
data
[
'in'
]
==
"all-inventories"
then
return
actor
:
findInAllInventoriesBy
(
node
.
data
.
search_by
,
node
.
data
.
search
)
...
...
@@ -192,7 +193,7 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
if
not
a
and
err
then
error
(
"[Chat] chatFormatActions ERROR: "
..
err
)
end
a
=
a
()
local
is_player
=
node
.
data
.
who
==
"player"
add_action
(
function
(
npc
,
player
)
return
(
is_player
and
player
or
npc
):
attr
(
node
.
data
.
attr
,
a
)
end
)
add_action
(
node
,
function
(
npc
,
player
)
return
(
is_player
and
player
or
npc
):
attr
(
node
.
data
.
attr
,
a
)
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"attr-get"
then
...
...
@@ -202,7 +203,7 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
if
not
a
and
err
then
error
(
"[Chat] chatFormatActions ERROR: "
..
err
)
end
a
=
a
()
local
is_player
=
node
.
data
.
who
==
"player"
add_cond
(
function
(
npc
,
player
)
add_cond
(
node
,
function
(
npc
,
player
)
local
actor
=
(
is_player
and
player
or
npc
)
local
v
=
actor
:
attr
(
node
.
data
.
attr
)
if
node
.
data
.
test
==
"?"
then
return
v
and
true
or
false
...
...
@@ -236,11 +237,11 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
elseif
node
.
name
==
"change-zone"
then
local
zone
=
nil
if
node
.
data
.
zone
~=
"--"
then
zone
=
node
.
data
.
zone
end
add_action
(
function
()
game
:
changeLevel
(
tonumber
(
node
.
data
.
level
),
zone
)
end
)
add_action
(
node
,
function
()
game
:
changeLevel
(
tonumber
(
node
.
data
.
level
),
zone
)
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"set-faction-reaction"
then
add_action
(
function
(
npc
,
player
)
add_action
(
node
,
function
(
npc
,
player
)
local
f1
=
node
.
data
.
f1
if
f1
==
"--player--"
then
f1
=
player
.
faction
end
local
f2
=
node
.
data
.
f2
...
...
@@ -257,8 +258,8 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
if
node
.
data
.
store
==
"game"
then
game
.
state
.
__chat_uniqueness
=
game
.
state
.
__chat_uniqueness
or
{}
store
=
game
.
state
.
__chat_uniqueness
end
return
store
end
add_cond
(
function
(
npc
,
player
)
local
store
=
getstore
(
npc
,
player
)
return
not
store
[
node
.
data
.
id
]
end
)
add_action
(
function
(
npc
,
player
)
local
store
=
getstore
(
npc
,
player
)
store
[
node
.
data
.
id
]
=
true
end
)
add_cond
(
node
,
function
(
npc
,
player
)
local
store
=
getstore
(
npc
,
player
)
return
not
store
[
node
.
data
.
id
]
end
)
add_action
(
node
,
function
(
npc
,
player
)
local
store
=
getstore
(
npc
,
player
)
store
[
node
.
data
.
id
]
=
true
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
---------------------------------------------------------------------------
elseif
node
.
name
==
"not"
then
...
...
@@ -290,7 +291,7 @@ function _M:chatFormatActions(nodes, answer, node, stop_at)
for
i
,
d
in
ipairs
(
table
.
sget
(
node
,
'inputs'
,
'input_2'
,
"connections"
)
or
{})
do
walk_chain
(
nodes
[
d
.
node
])
end
for
i
,
d
in
ipairs
(
table
.
sget
(
node
,
'inputs'
,
'input_3'
,
"connections"
)
or
{})
do
walk_chain
(
nodes
[
d
.
node
])
end
add_cond
(
function
(
npc
,
player
)
for
i
,
cond
in
ipairs
(
conds
)
do
if
cond
(
npc
,
player
)
then
return
true
end
end
end
)
add_cond
(
node
,
function
(
npc
,
player
)
for
i
,
cond
in
ipairs
(
conds
)
do
if
cond
(
npc
,
player
)
then
return
true
end
end
end
)
return
self
:
chatFormatActions
(
nodes
,
answer
,
getnext
(),
stop_at
)
else
return
self
:
triggerHook
{
"Chat:chatFormatActions"
,
nodes
=
node
,
answer
=
answer
,
node
=
node
,
add_action
=
add_action
,
add_cond
=
add_cond
,
getnext
=
getnext
,
stop_at
=
stop_at
}
...
...
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