Jump to content


Photo

Ruby/RGSS3 questions that don't deserve their own thread


  • Please log in to reply
1315 replies to this topic

#1261 Galv

Galv

    Forum Defender

  • Staff Manager/Global Mod
  • 4,960 posts
  • LocationAustralia
  • RM Skill - Jack of All Trades

Awards Bar:

Users Awards

Posted 27 February 2014 - 03:13 PM

Arakin, this topic is for ruby RGSS3 questions. For general RM support, next time please post in:

http://www.rpgmakerv...-rm-discussion/

 

Here is a tutorial on adding resource packs:

http://steamcommunit...s/?id=131363913


Those who toy with pure hearts
will someday be tried by pure hearts!

xwGfmy9.png


Spoiler

#1262 yomachi

yomachi

    Newbie

  • Ace Member
  • 7 posts

Posted 10 March 2014 - 03:08 AM

Hi. I'm new to RGSS so I need a little help with this...

$alfred_trait = "smart"

$npc_id = "$alfred"

$text_1 = "trait"

draw_text(0, 80, 136, 32, $npc_id + "_" + $text_1)

This gives me $alfred_trait.

How can I combine these so that it'll show smart instead without flat out doing...

draw_text(0, 80, 136, 32, $alfred_trait)


#1263 SoulpourVII

SoulpourVII

    Crownless King

  • Ace Member
  • 831 posts
  • LocationPhilippines
  • RM Skill - Coder

Posted 10 March 2014 - 03:21 AM

I'm sorry, what exactly do you want to show?


For the link of my scripts:

 

script_banner.jpg?w=200&h=200

 

I am a supporter of:

 

F2iYq0r.png?2Fdlq6er.gif P0zFTvB.png


#1264 yomachi

yomachi

    Newbie

  • Ace Member
  • 7 posts

Posted 10 March 2014 - 03:29 AM

I want it to show the value of $alfred_trait which is "smart".



#1265 SoulpourVII

SoulpourVII

    Crownless King

  • Ace Member
  • 831 posts
  • LocationPhilippines
  • RM Skill - Coder

Posted 10 March 2014 - 03:32 AM

you can use the draw_text_ex method instead.

draw_text_ex(x, y, $alfred_trait)

oh by the way, you're using global variables. Sometimes, its not really nice to use them esp. on drawing. If you're drawing this in a class, you can use modules instead, where you place alfred's trait.

module Yomachi
  Alfred_Trait = "Smart"
end

draw_text_ex(x, y, Yomachi::Alfred_Trait)

For the link of my scripts:

 

script_banner.jpg?w=200&h=200

 

I am a supporter of:

 

F2iYq0r.png?2Fdlq6er.gif P0zFTvB.png


#1266 yomachi

yomachi

    Newbie

  • Ace Member
  • 7 posts

Posted 10 March 2014 - 04:07 AM

Thanks for the tip. I didn't really know much about modules so I was trying to avoid it. ><

But is there any way I can create a combination of variables to create new variables?
I'm was hoping to avoid...

draw_text_ex(x, y, Yomachi::Alfred_Trait)

and instead making combinations such as...

draw_text_ex(x, y, Yomachi::npc_id + "_" + Yomachi::text_1)

...and still show smart.



#1267 SoulpourVII

SoulpourVII

    Crownless King

  • Ace Member
  • 831 posts
  • LocationPhilippines
  • RM Skill - Coder

Posted 10 March 2014 - 04:24 AM

Oh, you gave values to npc_id and text_1 here. the first code you showed was:


$npc_id = "$alfred"

$text_1 = "trait"

its not the same as $alfred_trait.

 

You gave values to each, but it doesn't mean that it would show you "smart" (which is the value of $alfred_trait variable).


For the link of my scripts:

 

script_banner.jpg?w=200&h=200

 

I am a supporter of:

 

F2iYq0r.png?2Fdlq6er.gif P0zFTvB.png


#1268 regendo

regendo

    Ruler of Worlds

  • Ace Member
  • 882 posts
  • LocationGermany
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 10 March 2014 - 05:34 AM

You could say something like

text = eval(Yomachi::npc_id + "_" + Yomachi::text_1)
# or if you're already inside a string
text = "#{eval(Yomachi::npc_id + "_" + Yomachi::text_1)}"

# eval() evaluates a code stored as a string. You can imagine this as stripping away both
# " marks and then just reading it as code. #{doStuffHere} can be used inside strings to
# execute code (otherwise you would just print "$alfred_trait").

Edited by regendo, 10 March 2014 - 05:36 AM.

Stay up-to-date with all of my scripts and my ToU on github! - /regendo/rgss3-scripts
@bStefann

#1269 SoulpourVII

SoulpourVII

    Crownless King

  • Ace Member
  • 831 posts
  • LocationPhilippines
  • RM Skill - Coder

Posted 10 March 2014 - 05:58 AM

Ohhh interpolation, I never thought you can just place it like that. Well, even I learned something new >_<


For the link of my scripts:

 

script_banner.jpg?w=200&h=200

 

I am a supporter of:

 

F2iYq0r.png?2Fdlq6er.gif P0zFTvB.png


#1270 Wren

Wren

    Advanced Member

  • Ace Member
  • 895 posts
  • RM Skill - Jack of All Trades

Posted 11 March 2014 - 11:10 PM

Looking for the bit of RGSS3 code that I can use in a common event that will return me to the skills menu after use and not impact anything if used in the battle scene.

 

Currently, when I use this common event from the skills menu on the field, the scene returned to is the field, not the skills menu for the character who used the skill.

 

I'd also like some way to check if the character is using it from battle, and if not using it from battle, have the ability to add in a choice option or conditional branch.


MHLRFS_zpsb2ef1590.png                                                   Xypher_zps2a06786a.png

Status:  Battle System----------------------------90%                                                 Has helped me bunches of times!

Status:  Plot-------------------------------------------15%                                                                                                   

Status:  Graphics------------------------------------65%                                                                                                   

Status:  Script Integration-----------------------90%                                                                                                   

 


#1271 Xypher

Xypher

    Advanced Member

  • Ace Member
  • 808 posts
  • RM Skill - Jack of All Trades

Posted 11 March 2014 - 11:24 PM

common events can only run from the map scene or battle scene which is why they return you to the map when you use them from the menu.

I'm not 100% sure but tsukihime's scene interpreter might change that behaviour.

 

$game_party.in_battle is the check for whether you're in battle or not.



#1272 Wren

Wren

    Advanced Member

  • Ace Member
  • 895 posts
  • RM Skill - Jack of All Trades

Posted 11 March 2014 - 11:49 PM

common events can only run from the map scene or battle scene which is why they return you to the map when you use them from the menu.

I'm not 100% sure but tsukihime's scene interpreter might change that behaviour.

 

$game_party.in_battle is the check for whether you're in battle or not.

I'll check out Tsuki's script.

 

I was successfully able to check if in battle using that variable, Xypher.

 

Any chance you know how I can check if a characters current MP?


MHLRFS_zpsb2ef1590.png                                                   Xypher_zps2a06786a.png

Status:  Battle System----------------------------90%                                                 Has helped me bunches of times!

Status:  Plot-------------------------------------------15%                                                                                                   

Status:  Graphics------------------------------------65%                                                                                                   

Status:  Script Integration-----------------------90%                                                                                                   

 


#1273 Xypher

Xypher

    Advanced Member

  • Ace Member
  • 808 posts
  • RM Skill - Jack of All Trades

Posted 11 March 2014 - 11:57 PM

depends from where you are checking, from a damage formula you'd use a.mp or b.mp or from an event you would use $game_actors[x].mp or $game_party.members[x].mp



#1274 Wren

Wren

    Advanced Member

  • Ace Member
  • 895 posts
  • RM Skill - Jack of All Trades

Posted 12 March 2014 - 12:17 AM

Xypher, you are a life saver, got that common event all set up and it works perfect, thanks again buddy!


MHLRFS_zpsb2ef1590.png                                                   Xypher_zps2a06786a.png

Status:  Battle System----------------------------90%                                                 Has helped me bunches of times!

Status:  Plot-------------------------------------------15%                                                                                                   

Status:  Graphics------------------------------------65%                                                                                                   

Status:  Script Integration-----------------------90%                                                                                                   

 


#1275 IceSage

IceSage

    Sage of Ice

  • Ace Member
  • 59 posts
  • LocationNetherspace
  • RM Skill - Jack of All Trades

Posted 13 March 2014 - 11:27 PM

Removing 1 line from a definition?

 

Is it even possible to remove 1 piece of code from a definition? I currently find myself able to add new lines of code to a definition, by either calling an alias or super, and just entering the line(s) of code I want to add. However, say I have a long string of code and I want to remove a line. Does the definition need to be completely overwritten in order to remove something?

 

Example:

def hello_world
   a = "Hello"
   b = "World"  #<- I want to remove this.
   c = "again"
   d = "buddy"
end

#So if I wanted to overwrite the previous hello_world...
#
#...The final code looks like this:

def hello_world #example 2
   a = "Hello"
   c = "again"
   d = "buddy"
end

#I know I can add something new to an existing one by

def hello_world
  super()
  e = "one more time"
end

#Or an alias

alias ice_new_hello_world hello_world
 def hello_world
   ice_new_hello_world
   e = "one more time"
end

#But how would I remove just 1 piece completely?

I'm not sure if this makes sense. Currently I find myself just copying / pasting the definition over again and removing the line I don't want, like "Example 2" -- But is there an easier way? If feel there is and while I'm trying to teach myself to code, I feel like I'm adding extra lines of code that could be simpler just to remove 1 piece.


Edited by IceSage, 13 March 2014 - 11:27 PM.

Jack of all Trades! - (...Master of none.)


#1276 TheoAllen

TheoAllen

    Wandering Hunter

  • Ace Member
  • 234 posts
  • LocationIndonesia
  • RM Skill - Coder

Posted 13 March 2014 - 11:50 PM

Well, you can't. That's why I hate RGSS / RMXP Script. I swear I won't touch it ~


My scripts collection :
http://theolized.blogspot.com/
Sorry if I made it in Indonesian

Supporter of :
1viwZUi.png

Make your own party composition based on 31 playable characters :
Um49Knu.gifatgZMqB.gifVSYyHJW.gifuQg15JR.gifGMwnDzr.gifJXX3YES.gifG6PbyQB.gift1SSEgm.gifLZANXrT.gifQrsC7UF.gifklkNdKW.gifDFIr27Z.gifOsRSVVA.gifWhpXAKn.gifBgkgoFS.gifE6O3uwJ.gifDrZBJAC.gifTUJhJFi.gifXjwwARd.gifDCfyJEZ.gif0jiqJzm.gifijRP96L.gifpz33g0h.giflEgJ4Pi.gifEIXXKvC.gifNp1wQef.gifwZeJbQs.gifz5r213j.gifjko7j44.gifL0laUN4.gifBr3m9MN.gif


#1277 IceSage

IceSage

    Sage of Ice

  • Ace Member
  • 59 posts
  • LocationNetherspace
  • RM Skill - Jack of All Trades

Posted 14 March 2014 - 12:46 AM

Well, you can't. That's why I hate RGSS / RMXP Script. I swear I won't touch it ~

 

If that's true that's good for me because I felt like I was a moron not knowing how to do it and thought "I hope I'm not doing this wrong." It felt kind of silly copying and pasting entire lines of code just to replace / remove 1 line.

 

I don't mind doing it, as long as it's the only way. I can understand your frustration, though, however it doesn't bother me. (Yet.) 

 

Thanks for the reply!


Edited by IceSage, 14 March 2014 - 12:47 AM.

Jack of all Trades! - (...Master of none.)


#1278 Xypher

Xypher

    Advanced Member

  • Ace Member
  • 808 posts
  • RM Skill - Jack of All Trades

Posted 14 March 2014 - 01:03 AM

seems like it would be easier just to use an array or hash to have your strings predetermined from your example ice



#1279 IceSage

IceSage

    Sage of Ice

  • Ace Member
  • 59 posts
  • LocationNetherspace
  • RM Skill - Jack of All Trades

Posted 14 March 2014 - 01:17 AM

seems like it would be easier just to use an array or hash to have your strings predetermined from your example ice

 

The example was just meant to show what I was talking about, not actually intended as a working code. I wouldn't setup something like that if I were writing something. But thanks! :D


Edited by IceSage, 14 March 2014 - 01:17 AM.

Jack of all Trades! - (...Master of none.)


#1280 Mildon

Mildon

    Newbie

  • Ace Member
  • 1 posts

Posted 19 March 2014 - 04:31 AM

I'm not sure if this is the right place but... In RGSS3 How and why do you use dispose?

class C1
  def initialize
  end
  
  def dispose
  end
  
  def F1
    msgbox_p("Dispose Failed")
  end
end

a1 = C1.new
a1.dispose
a1.F1

From a tutorial I thought it would remove the instance of the class from your memory but it seems to still be there. When I start the game I get "Dispose Failed" even though I thought a1 shouldn't exist anymore. I might be misunderstanding but classes that you create stay until you restart your computer?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users