Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Macro XP/VX

Easy Macro
Version:1.1.0.3
By: Lionel

Introduction
Hello, This Macro Script Helps You With Rewriting Code
The Macro Is A Set Of Common Commands You Would use,
Like Constantly Using a long number(5.54545449998731973218456264) In your Code.
This Makes Script writing easier
Instructions
Paste the Script In The Script Editor Above Main , Then Edit The Commands Where #Type Message Here and #Put objects in here are.
Then Use The Commands That It Shows In Your Own Script To Make Scripting Easier
Screenshots
Its Impossible To Take A Screen Shot
Features
Macro Objects
Macro Message
Macro Block
Macro Cache
Script
[rgss] 
#==============================================================
#Easy Macro 1.3
#By Lionel
#==============================================================
#To Use A Macro object, Use Macro.ob(Command Number)
#To Use A Macro message, Use Macro.msg(Message Number)
module System
  class Macro
      #Add Username Here!
      User=""
      if User=""
        print 'Exerption:BAD DATA(Please rant about this to the owner,(Type:NO NAME!)"
     #------------------------------------------------------------
     #Macro/Object (MO)
     #------------------------------------------------------------
     def self.ob(num)
        if num==1
           return mcrarr=[]#Put objects in here
        elsif num==2
           return mcrhsh={}#Put objects in here
        elsif num==3
           return mcrsng=''#Put objects in here
        else
           print 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Out of bounds args)"
        end
     end
     #------------------------------------------------------------
     #Macro/Message (MM)
     #------------------------------------------------------------
     def self.msg(msg)
        if msg==1
           print ''#Type Message Here
        elsif msg==2
           print ''#Type Message Here
        elsif msg==3
           print ''#Type Message Here
       else
         print 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Out of bounds args)"
        end
     end
     #-------------------------------------------------------------
     #Macro/Block (MB)
     #-------------------------------------------------------------
     def self.bck1
        #Put A Heavily Used Block Here
     end
     def self.bck2
        #Put A Heavily Used Block Here
     end
     def self.bck3
        #Put A Heavily Used Block Here
     end
     #--------------------------------------------------------------
     #Macro/Cache (MC)
     #--------------------------------------------------------------
     def self.Che
        $Cache=[]
        def Che.del
           $Cache=nil
        end
        def Che.clr
           if $Cache==[]
              print 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Object Empty)"
           else
              $Cache=[]
           end
        end
      end
   end
 end
end
 
 
<span style="color:#996600;"
[/rgss]
How to use
[rgss] 
include System
Macro.#Add something here!
 
[/rgss]
Compatibility
This Script Works In XP And VX
Credits and Thanks
I Don't Require Credit (But It's ok!)
Author's Notes
If Your Making A Script With This, Post The Macro You Used.
 
I don't understand how to use your script.
PI.new is longer than
Code:
include Math

Pi
And about the print messages you can also use Constants...

berka
 
I Don't Know What You Mean About The Constants But This Is How It Works,
Your Making A Script In XP/VX and You Use A Array,Hash,string, or message In Many Classes.
You Put The Frequently Used Array,Hash,string, or message in the slot
Slots
[rgss]$mcrarr=[]#Put array objects in here
$mcrhsh={}#Put hash objects in here
$mcrsng=''#Put Text in here
print ''#Type Message Here
print ''#Type Message Here
print ''#Type Message Here
 
[/rgss]
Then Call The Function In The Code

Funtions
[rgss]Macro.ob(num)#num Is The Object Number
Macro.msg(msg)#msg Is The Message Number
 
[/rgss]
Here's A Edited Macro
[rgss]#==============================================================
#Easy Macro
#By Lionel
#==============================================================
#To Use A Macro object, Use Macro.ob(Command Number)
#To Use A Macro message, Use Macro.msg(Message Number)
begin
  Macro=self
  #------------------------------------------------------------
  #Macro/Object (MO)
  #------------------------------------------------------------
  def Macro.ob(num)
    if num==1
      $mcrarr=['Berka Rules','Go RMXP.org!']#Put objects in here
    elsif num==2
      $mcrhsh={Zeraib=>'Friend'}#Put objects in here
    elsif num==3
      $mcrsng='Regi And Near Are Nice'#Put objects in here
    else
      print 'Macro Error'
    end
  end
  #------------------------------------------------------------
  #Macro/Message (MM)
  #------------------------------------------------------------
  def Macro.msg(msg)
    if msg==1
      print 'Error in Pizza'#Type Message Here
    elsif msg==2
      print 'This Is Macro 1.0'#Type Message Here
    elsif msg==3
      print 'The Great Red Fox Jumped Over The Lazy Dog'#Type Message Here
    end
  end
end
[/rgss]
To Call Object 3 Do This
Code:
Macro.ob(3)
To Call Message 3 Do This
Code:
Macro.msg(3)
 

Jason

Awesome Bro

So let me get this right, say, for example....

I make an array which I will be using multiple times, I can write it into Macro.obj as object 1, and have like;

Array = [1, 2, 3, 4, 5...]

So everytime I want to call this array, I just use;

Macro.obj(1)

Am I right in thinking this ? Cause if so, that could become pretty handy for the large scale scripters, I mean, I'm still in the process of learning most of the scripting functions etc, but this seems like it could be really handy.
 
Well, that's not really a tool script, it's more likely an advice on how to script things, and I must say that doing "Macro.ob(id)" is not much useful as it hasn't a intuitive name. But that's just my personal opinion, keep scripting
Also, I noticed an error in:
Code:
    if $Cache=[]

      print 'Macro/Cache Error'
It should be $Cache==[] or $Cache.empty?.
 
pretty useless script except for the learning process of conditional statement...

as Berka said, you can do that with constants, it's much simpler, and flexible as well...
if i got an object I use a lot
i create a constant in the main scope or maybe a special module storing all of my constants...none the less, those constant are accessible from everywhere without being global variables ( brr global = bad )

A constant holding an object doesn't mean the object can't change its state, it means the constant can't change the reference to the object it's holding.
 

Zeriab

Sponsor

It should be noted that constants in Ruby are not really constants.

Why do you create the extra methods for nil?
You can do stuff like nil.ob(2) and nil.msg(1).

Why do you set both Macro and Che to nil?

Why have you decided that you must use nil.che before you can use the $Cache?

*hugs*
 
Zeriab, why are speaking of nil? self isn't nil by default, it's "main" , an instance of the object class.
( i suggest you do : p self, self.class in irb or in the script editor )

About constants, they are constant to the reference of the value they hold, but ruby is also too nice with the user by only sending a warning when a constant's reference is changed.

Let's say, i got a constant "my fruit" which has "a value" of "an apple",
after some time my apple rot, and my apple's state has changed, but my fruit is still that same apple.
 

Zeriab

Sponsor

Because self is nil in RMXP at the start of the script editor. (Strange, I know)
In RMVX you are right about it being main, I hadn't checked VX before.
 
:huh:

Code:
module System

  class Macro

    begin

Why begin? And why is Macro a class? And why is Macro a class with the System module?

------------------------------

Code:
         if num==1

           return mcrarr=[]#Put objects in here

        elsif num==2

           return mcrhsh={}#Put objects in here

        elsif num==3

           return mcrsng=''#Put objects in here

        else

           print 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Out of bounds args)"

        end

Read about case statements.
Code:
 

case object

when 1

  # do something

when 2

  # do something

And why would you assign returned values to local variables?
return mcrarr=[]

You can more effectively just return the array

------------------------------------

Code:
#       def self.msg(msg)

#         if msg==1

#            print ''#Type Message Here

#         elsif msg==2

#            print ''#Type Message Here

#         elsif msg==3

#            print ''#Type Message Here

#        else

#          pprint 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Out of bounds args)"

#         end

#      end

pprint is a syntax error.
and how often is
- System::Macro.msg(n)
going to be any easier than
- p 'message'

It would just be easier to throw together (I guess) a hash constant with id and strings instead:
Code:
 

module Whatever

  Msg = {

    1 => 'some string',

    2 => 'some string',

    #...

  }

And then just p Whatever::Msg, as with here, you aren't calling a function and returning an object after passing through an expression. You are just return an object defined in a constant.

-------------------------------------

Code:
      def self.Che

        $Cache=[]

        def Che.del

           $Cache=nil

        end

        def Che.clr

           if $Cache==[]

              print 'Exerption:BAD DATA(Please rant about this to'+User+",(Type:Object Empty)"

           else

              $Cache=[]

           end

        end

      end

defining a global variable within a method, then defining 2 methods within a method? :huh: Why print that annoying message if your $Cache is an empty array? Why not just stop method processing?

---------------------------------

You would never need to "include System" unless you wanted your "Macro" class included within a class or module (redundant). At very best, you would include module methods within a class (mixins).

-----------------------------

I understand what you are going for, however, this is more of a "concept" that people could include in their projects to perform various often called functions and stuff, but would always be better suited for a specific module (IE: creating a method to check something such as distance between points, in the Math module).
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top