RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Solved] [VX ACE] Is this corectly coded ?

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 57
RMRK Junior
Hello,

Can someone help me check if this script is correctly coded, please ?
A friend tried to teach how to script months ago and this is the result.
But I'm unable at the moment to meet him.

The purpose of this script is to help me call a sprite from a sprite sheet and to change it to my taste through a script command in an event. Yes, I'm more an eventer than a scripter...
Code: [Select]
class Chara < Game_Interpreter
 
 def  initialize(id, type, nom, x=0, y=0, z=0, m)
    sprite = Sprite.new
   
    sprite.x = x
    sprite.y = y
    sprite.z = z
   
    sprite.mirror = m
    m = false
   
    chemin = "Graphics/Units/#{type}/#{nom}"
    sprite.bitmap = Cache.normal_bitmap(chemin)
   
    w = sprite.width/3
    h = sprite.height/5
    sprite.src_rect.set(0, 0, w, h)
   
    V[id] = sprite
  end
 
    def self.frame(id, frame)
     V[id].src_rect.x = frame*V[id].width
   end
   
   def self.pose (id, pose)
     V[id].src_rect.y = pose*V[id].height
   end
   
    def self.add(id, type, nom)
      chemin = "Graphics/Units/#{type}/#{nom}"
      bitmap = Cache.normal_bitmap(chemin)
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      V[id].bitmap.blt(0, 0, bitmap, rect)
      end
   end
« Last Edit: August 10, 2014, 01:39:00 AM by yuyu! »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
It LOOKS fine...
I can think of improvements to the code. But you'll figure those out yourself in time and with experience :)


Brief mention:
Code: [Select]
   w = sprite.width/3
    h = sprite.height/5
    sprite.src_rect.set(0, 0, w, h)
This assumes that the spritesheet (should you ever use any different one) will always contains 3 sprites horizontally and 5 sprites vertically.
If that is ever not the case. Your result will end up looking incredibly weird.


I'm not sure what you want me to critique here, I mean the code looks fine, it looks as though it should do as you have said.
Is that all you wanted to know? Does it not work?


All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep:
Level 57
RMRK Junior
Thank you for your reply.
I'm happy to know that the script is correct.