[XP][VX] Wecoc Database Eval Script

Started by Wecoc, February 05, 2014, 05:46:50 pm

Previous topic - Next topic

Wecoc

February 05, 2014, 05:46:50 pm Last Edit: February 05, 2014, 07:23:29 pm by KK20
Wecoc Database Eval Script 1.0
Authors: Wecoc
Version: 1.0
Type: Database Feature
Key Term: Misc Add-on



Introduction

This script allows you to insert eval (script calls) in database name boxes. There are some examples on the script, as well as where you can use it (basically, in all the non-numeric holes which database lets you write crap). Some boxes have a very limited space to write, so I added the option to use Shortcuts and to create your own easily. You can use those in every script call.



Features


  • Use both eval and default names

  • Set your own shortcuts




Screenshots

I think it makes no sense for this type of script.


Demo

No demo.


Script

XP version:
Spoiler: ShowHide

#==============================================================================
# ** [XP] Wecoc Database Eval Script 1.0
#==============================================================================

# ------------- INTRODUCTION --------------------------------------------------

# This script allows to use eval in database string inputs.
# You can name an item as always, but with this you have several more options.

# --------------- EXAMPLES ----------------------------------------------------

#   Potion
#   $game_variables[1]
#   "Potion" + var[1]
#   "Radar: #{map.to_s}"
#   "Poison, rating #{self.rating}"
#   act[0].name + "'s Shield"
#   map == 1 ? "Poison" : "Toxic"

# ------------- WHERE TO USE --------------------------------------------------

# Database --> Actors   --> Name (This makes no sense)
# Database --> Classes  --> Name
# Database --> Skills   --> Name + Description
# Database --> Items    --> Name + Description
# Database --> Weapons  --> Name + Description
# Database --> Armors   --> Name + Description
# Database --> Enemies  --> Name
# Database --> Troops   --> Name
# Database --> States   --> Name
# Database --> Animations-> Name (This makes no sense)
# Database --> Tilesets --> Name (This makes no sense)
# Database --> C. Events -> Name (This makes no sense)
# Database --> System   --> Atributes + Words (Gold, HP ...)

# --------------- CREDITS -----------------------------------------------------

# Author: Wecoc

#==============================================================================


module Wecoc_Eval
 def check_eval(n)
   $testing = true
   eval = get_eval(n)
   $testing = false
   if eval == "Exception"
     return n
   else
     return eval(n).to_s
   end
 end
 
 def get_eval(n)
   return begin
     eval(n).to_s
   rescue Exception
     "Exception"
   end
 end
 
 # Shortcuts [ Add as many as you want ]
 
 def var
   return $game_variables
 end
 
 def stch
   return $game_switches
 end
 
 def act
   return $game_party.actors
 end
 
 def map
   return $game_map.map_id
 end
end

module RPG
 class Actor
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Animation
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Armor
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def description
     return check_eval(@description)
   end    
 end

 class Class
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class CommonEvent
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Enemy
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Event
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Item
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def description
     return check_eval(@description)
   end    
 end
 
 class MapInfo
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Skill
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def description
     return check_eval(@description)
   end    
 end
 
 class State
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class System
   include Wecoc_Eval
   def elements
     array = [nil]
     for i in 1...@elements.size
       array.push(check_eval(@elements[i]))
     end
     return array
   end
   
   class Words
     include Wecoc_Eval
     def gold
       return check_eval(@gold)
     end
     def hp
       return check_eval(@hp)
     end
     def sp
       return check_eval(@sp)
     end
     def str
       return check_eval(@str)
     end
     def dex
       return check_eval(@dex)
     end
     def agi
       return check_eval(@agi)
     end
     def int
       return check_eval(@int)
     end
     def atk
       return check_eval(@atk)
     end
     def pdef
       return check_eval(@pdef)
     end
     def mdef
       return check_eval(@mdef)
     end
     def weapon
       return check_eval(@weapon)
     end
     def armor1
       return check_eval(@armor1)
     end
     def armor2
       return check_eval(@armor2)
     end
     def armor3
       return check_eval(@armor3)
     end
     def armor4
       return check_eval(@armor4)
     end
     def attack
       return check_eval(@attack)
     end
     def skill
       return check_eval(@skill)
     end
     def guard
       return check_eval(@guard)
     end
     def item
       return check_eval(@item)
     end
     def equip
       return check_eval(@equip)
     end
   end
 end
 
 class Tileset
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Troop
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
 
 class Weapon
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def description
     return check_eval(@description)
   end    
 end
end

class Interpreter
 include Wecoc_Eval
end

class SystemStackError < Exception
 alias testing_exception initialize unless $@
 def initialize
   return if $testing
   testing_exception
 end
end


VX version:
Spoiler: ShowHide

#==============================================================================
# ** [VX] Wecoc Database Eval Script 1.0
#==============================================================================

# ------------- INTRODUCTION --------------------------------------------------

# This script allows to use eval in database string inputs.
# You can name an item as always, but with this you have several more options.

# --------------- EXAMPLES ----------------------------------------------------

#  Potion
#  $game_variables[1]
#  "Potion" + var[1]
#  "Radar: #{map.to_s}"
#  "Poison, rating #{self.rating}"
#  act[0].name + "'s Shield"
#  map == 1 ? "Poison" : "Toxic"

# ------------- WHERE TO USE --------------------------------------------------

# Database --> Actors  --> Name (This makes no sense)
# Database --> Classes  --> Name + Command Name
# Database --> Skills  --> Name + Description + Message 1 + Message 2
# Database --> Items    --> Name + Description
# Database --> Weapons  --> Name + Description
# Database --> Armors  --> Name + Description
# Database --> Enemies  --> Name
# Database --> Troops  --> Name
# Database --> States  --> Name + Message 1 + Message 2 + Message 3 + Message 4
# Database --> Animations-> Name (This makes no sense)
# Database --> C. Events -> Name (This makes no sense)
# Database --> System  --> Atributes
# Database --> Terms

# --------------- CREDITS -----------------------------------------------------

# Author: Wecoc

#==============================================================================


module Wecoc_Eval
 def check_eval(n)
   $testing = true
   eval = get_eval(n)
   $testing = false
   if eval == "Exception"
     return n
   else
     return eval(n).to_s
   end
 end

 def get_eval(n)
   return begin
     eval(n).to_s
   rescue Exception
     "Exception"
   end
 end

 # Shortcuts [ Add as many as you want ]

 def var
   return $game_variables
 end

 def stch
   return $game_switches
 end

 def act
   return $game_party.actors
 end

 def map
   return $game_map.map_id
 end
end

module RPG
 class Actor
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Animation
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Area
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class BaseItem
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def description
     return check_eval(@description)
   end  
 end

 class Class
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def skill_name
     return check_eval(@skill_name)
   end
 end

 class CommonEvent
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Enemy
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Event
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class MapInfo
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end

 class Skill
   include Wecoc_Eval
   def message1
     return check_eval(@message1)
   end
   def message2
     return check_eval(@message2)
   end  
 end

 class State
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
   def message1
     return check_eval(@message1)
   end
   def message2
     return check_eval(@message2)
   end  
   def message3
     return check_eval(@message3)
   end
   def message4
     return check_eval(@message4)
   end  
 end

 class System
   include Wecoc_Eval
   def elements
     array = [nil]
     for i in 1...@elements.size
       array.push(check_eval(@elements[i]))
     end
     return array
   end
 
   class Terms
     include Wecoc_Eval
     def level
       return check_eval(@level)
     end
     def level_a
       return check_eval(@level_a)
     end
     def hp
       return check_eval(@hp)
     end
     def hp_a
       return check_eval(@hp_a)
     end
     def mp
       return check_eval(@mp)
     end
     def mp_a
       return check_eval(@mp_a)
     end
     def atk
       return check_eval(@atk)
     end
     def def
       return check_eval(@def)
     end
     def spi
       return check_eval(@spi)
     end
     def agi
       return check_eval(@agi)
     end
     def weapon
       return check_eval(@weapon)
     end
     def armor1
       return check_eval(@armor1)
     end
     def armor2
       return check_eval(@armor2)
     end
     def armor3
       return check_eval(@armor3)
     end
     def armor4
       return check_eval(@armor4)
     end
     def weapon1
       return check_eval(@weapon1)
     end
     def weapon2
       return check_eval(@weapon2)
     end
     def attack
       return check_eval(@attack)
     end
     def skill
       return check_eval(@skill)
     end
     def guard
       return check_eval(@guard)
     end
     def item
       return check_eval(@item)
     end
     def equip
       return check_eval(@equip)
     end
     def status
       return check_eval(@status)
     end
     def save
       return check_eval(@save)
     end
     def game_end
       return check_eval(@game_end)
     end
     def fight
       return check_eval(@fight)
     end
     def escape
       return check_eval(@escape)
     end
     def new_game
       return check_eval(@new_game)
     end
     def continue
       return check_eval(@continue)
     end
     def shutdown
       return check_eval(@shutdown)
     end
     def to_title
       return check_eval(@to_title)
     end
     def cancel
       return check_eval(@cancel)
     end
     def gold
       return check_eval(@gold)
     end
   end
 end

 class Troop
   include Wecoc_Eval
   def name
     return check_eval(@name)
   end
 end
end

class Game_Interpreter
 include Wecoc_Eval
end

class SystemStackError < Exception
 alias testing_exception initialize unless $@
 def initialize
   return if $testing
   testing_exception
 end
end




Instructions

It's so simple, just use the boxes as if they were script calls.
You can use Potion as a name, but also $game_party.actors.select{|x| x.name.size < 5}[0].name + " Shield" rescue "Hero Shield"


Compatibility

Not incompatibility issues known.


Credits and Thanks


  • Wecoc





Author's Notes

Don't hesitate to ask any questions about the code.
Remember variables can have any value, also text, for example $game_variables[1] = "Mana Potion"

KK20






   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!