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.
Using Messages in RGSS

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 90
I want to make the Change Items event tell you when you have received an item, but I can't figure out how to call the standard message function from inside a script. I'm also trying to make it figure out whether your gaining or loosing the item, and if it's more than one at a time, how many were gained/lost.

My half-assed changes have been commented out

Code: [Select]
  #--------------------------------------------------------------------------
  # * Change Items (From Interpreter4)
  #--------------------------------------------------------------------------
  def command_126
    ## changed_item = @parameters[1]
    ## if value is not negative
    ## $game_temp.message_text = "You gained \C[1]" + $data_items[changed_item].name + "\C[0]!"
    ## else #losing item
    ## $game_temp.message_text = "You lost \C[1]" + $data_items[changed_item].name + '\C[0]!"

    # Get value to operate
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    # Increase / decrease items
    $game_party.gain_item(@parameters[0], value)
    # Continue
    return true
  end
My strength is that of ten men, for I am wired to the eyeballs on espresso!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, you have the right idea: all you need to do is change $game_temp.message_text

You have some syntax problems though. Before that though, your stuff should be below "value = operate ...." line, and @parameters[1] doesn't hold the item, @parameters[0] does. For syntax, the condition ought to be:

if value > 0

Instead of havine else, you ought to have elsif value < 0 since you don't want a message to play in the rare case that the value is 0 (which can happen).

and you mess up the quotations on the last \c[0] - one is a single quote and the other a double quote. You are also missing the end.
so your method should look like this:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Change Items (From Interpreter4)
  #--------------------------------------------------------------------------
  def command_126
    # Get value to operate
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    changed_item = @parameters[0]
    if value > 0
      $game_temp.message_text = "You gained \C[1]" + $data_items[changed_item].name + "\C[0]!"
    elsif value < 0
      $game_temp.message_text = "You lost \C[1]" + $data_items[changed_item].name + "\C[0]!"
    end
    # Increase / decrease items
    $game_party.gain_item(changed_item, value)
    # Continue
    return true
  end

Anyway, I haven't tested, so I may have missed something, but try that.

**
Rep: +0/-0Level 90
ThanksĀ  ;D
I'll try that

Spoiler for:
Edit: That seems to work, at least when I replace the message with plain text. It doesn't seem to like the concatenated string. Maybe if I converted $data_items[changed_item].name into a string before I tried to use it?

Nope, that didn't seem to work.
I'm still getting a syntax error here on like 227, am I not using the right operator for string concatenation? Some languages are & or &&, but I can't seem to find anything definitive in the RMXP help file.

Edit Again: Actually it seems to be the color codes that are making it temperamental. I think RGSS is trying to use the escaped color codes as variables - how you can put a variable in a string in some languages by escaping it - because it seems to work fine without the color codes.
Maybe I'll just go hack the window_message to use different formatting for the colors.

Another problem here if anyone has any ideas: Now that I have the messages, they don't ever go away. It took a lot of detective work to figure out that setting the message to != nil called it, but I can't seem to figure out how to uncall it the way the events do. (This was resolved, for some reason the messages started uncalling automatically  ???)

Edit Yet Again: Oh my bad. If I escape the escape there isn't any need to edit the escape. Now that nobody knows what I'm talking about:

Edit Yet Again:
It turns out the messages aren't auto uncalling. It still gets stuck in a loop popping up the message; but it just so happens with the event I tested this with there was a second message in the event code - which was properly disposing - ending the cycle.
« Last Edit: January 01, 2009, 09:49:28 PM by Zethzune »
My strength is that of ten men, for I am wired to the eyeballs on espresso!

**
Rep: +0/-0Level 90
Okay this all works except the message system gets stuck in a loop and keeps displaying the message every time you press Space/Enter/C. If there is a message in the Event after the change items it calls that - after the message from the event is displayed the loop ends.

I can't figure out how to end the loop otherwise.

Code: [Select]
  def command_126
    # Get value to operate
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    # Increase / decrease items
    changed_item = @parameters[0]
    if value > 0
      if value != 1
        $game_temp.message_text = "You gained \\C[1]" + value.to_s + " " + $data_items[changed_item].name + "\\C[0]!"
      else
        $game_temp.message_text = "You gained \\C[1]" + $data_items[changed_item].name + "\\C[0]!"
      end
    elsif value < 0
      if value != -1
        $game_temp.message_text = "You lost \\C[1]" + value.to_s + " " + $data_items[changed_item].name + "\\C[0]!"
      else
        $game_temp.message_text = "You lost \\C[0]" + $data_items[changed_item].name + "\\C[0]!"
      end
    end
    $game_party.gain_item(@parameters[0], value)
    # Continue
    return true
  end
My strength is that of ten men, for I am wired to the eyeballs on espresso!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, add this:


    # Set message end waiting flag and callback
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }

before the message setting. - Make sure to do so only when you are setting a message though. Hopefully that will work.
« Last Edit: January 01, 2009, 10:42:21 PM by Modern Algebra »

**
Rep: +0/-0Level 90
Thanks that worked - Well I think it did, I only tested it one place, but it seemed to work as advertised.

I inserted it above the If statement because there's no way it can go through my If without sending a message.
My strength is that of ten men, for I am wired to the eyeballs on espresso!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
For the one that you posted before there is. if value == 0 it will go through without sending a message.

It won't be common, but it's possible