RGSS scripting dissections and explinations
#61
I was talking about Evil Pod Pod not ordinary Pod Pod Tongue sticking out

The following is based on a method you may find in my KWork module, part of my KWorkshop XP Kustom Version script.

Code:
def lift_equip_curse(caster, level, thing)
    return if thing == nil
    thing.cursed = cursed = case caster
    when :priest, :clerigo then thing.curse_level > level
    when :smith, :herrero then thing.curse_level + 1 > level
    when :tech, :tecnico then thing.curse_level + 2 > level
    end
    return !cursed
  end

lift_equip_curse is a module specific method so you can only call it by mentioning its owner, the KWork module.

KWork.lift_equip_curse

As it is it should pop up an error message because that methods asks for 3 kind of specific arguments or values or stuff to put in.

KWork.lift_equip_curse(caster, level, thing)

What are caster, level and thing? Well, they're variables it needs to receive to lift a curse found either on a weapon or armor, that's what thing is doing there, to represent a weapon or armor. Then caster would be a symbol, those that start with colon : like :priest or :smith or :tech, and level would be some integer number (1, 2, 3 or any other you can think off).

return if thing == nil

It will make the KWork module stop processing the lift curse request, returning to the place it was before it was called, if thing is no real weapon or armor but just nothing instead or nil.

thing.cursed = cursed = case caster

In my script all weapons and armors have a class method named cursed that represents what the word itself stands for. case caster starts a complex comparison where every single possible result you will include in the following lines will be tested thoroughly. I already told what caster is.

when :priest, :clerigo then thing.curse_level > level

So it means that whenever the caster is :priest or :clerigo and nothing else (I do speak English and Spanish so I sometimes add Spanish terms as well, the German term is the same as in English so I did not need to add anything) the weapon or armor's curse_level is higher than the caster's level named level, then the equipment will be cursed automatically or will remain so, if it already was.

return !cursed

It will deliver the opposite value of the curse the weapon may or may not have on it. If it's cursed it will tell you the lifting process failed (false). It'd be a different story if it's not cursed, then the process was successful (true). Both true and false are normally called boolean or boolean values, you would need to learn some programming story to find out why, the long story short would be they were created to tell people if an evaluation, a test, ended as expected. being accurate (true) or inaccurate (false), perfect match (true) or a bad one (false), a good person (true) or a bad one (false), depending on what were you asking awhile before.

! there means not, the opposite of cursed in the case found above.

Recall I told you level could be an integer number, it does not mean you always need to type a number like 10, it could also be a class method like...

$game_actors[7].priest_level

...which would also return an integer, namely 0, Gloria's current priest level, she has not learned anything as how to sell her healing skills to people, including her fellow party members Tongue sticking out Remember she is the seventh actor or heroine in the database.

level = $game_actors[7].priest_level
KWork.lift_equip_curse(:priest, level, thing)

That's how the script call would look like then... but we better come up with a thing replacement! Tongue sticking out

Let's say her weapon is a mace so it could be...

gloria_weapon = $data_weapons[21].dup

I used dup that stands for duplicate or copy, a copy if the weakest mace available there. $data_weapons is the list of all weapins available in the maker.

The final and useful version of the script call would be...

gloria_level = $game_actots[7].priest_level
gloria_weapon = $data_weapons[21].dup
KWork.lift_equip_curse(:priest, gloria_level, gloria_weapon)
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
RE: RGSS scripting dissections and explinations - by kyonides - 01-23-2018, 10:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Help iwth script (RGSS Player crash) Whisper 3 8,529 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,915 11-03-2015, 06:16 AM
Last Post: kyonides
   Scripting in VX vs VX Ace Miharu 5 9,090 02-21-2015, 10:10 AM
Last Post: Taylor
   Combat animations via scripting; How? ZeroSum 2 5,113 09-20-2013, 06:58 PM
Last Post: ZeroSum
Question  RGSS stoped to work Chaos17 5 7,747 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 10,884 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 11,907 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 4,228 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Scripting I think spazfire 7 10,170 04-12-2010, 03:21 AM
Last Post: DerVVulfman
   Beginner Scripting Tuts? KDawg08 1 4,137 03-31-2010, 11:03 PM
Last Post: Hsia_Nu



Users browsing this thread: 14 Guest(s)