-
Notifications
You must be signed in to change notification settings - Fork 12
/
Page Condition Eval Script.rb
73 lines (64 loc) · 2.2 KB
/
Page Condition Eval Script.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# =============================================================================
# TheoAllen - Page Condition Eval Script
# Version : 1.0
# Contact : Discord @ Theo#3034
# =============================================================================
($imported ||= {})[:Theo_PageConditionScript] = true
# =============================================================================
# CHANGE LOGS:
# -----------------------------------------------------------------------------
# 2013.08.11 - Finished script
# =============================================================================
=begin
Introduction :
By default, there's no such a thing called event page condition eval script
like in conditional branch. This script allow you to add page condition
depends on script eval
How to use :
Put this script below material but above main
Use this following tags in event comments
<eval cond>
script
</eval cond>
If you use many lines, it will be considered as one line
Terms of use :
Credit me, TheoAllen. You are free to edit this script by your own. As long
as you don't claim it yours. For commercial purpose, don't forget to give me
a free copy of the game.
=end
# =============================================================================
# No configuration
# =============================================================================
class Game_Event < Game_Character
alias theo_eval_script_conditions_met? conditions_met?
def conditions_met?(page)
script = obtain_script_condition(page.list)
unless script.empty?
return eval(script)
end
return theo_eval_script_conditions_met?(page)
end
def obtain_script_condition(list)
result = ""
add_string = false
list.each do |cmd|
code = cmd.code
next unless code == 108 || code == 408
case cmd.parameters[0]
when /<(?:EVAL_COND|eval cond)>/i
add_string = true
when /<\/(?:EVAL_COND|eval cond)>/i
add_string = false
else
next unless add_string
result += cmd.parameters[0]
end
end
return result
end
def variables
if $imported[:THEO_EventVariable]
return $game_self_variables[$game_map.id,@id]
end
end
end