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.

A scripting name changing program issue

Well, recently I began work on a name changing program, accessible via scripting, that will be compatible with the typing system here (made by minkoff?). AT ANY RATE: i'm having issues with it, an argument error, 0 for 2, and  then x and y are undefined. Here:
Code:
#Name Typer Script
#Easy Usage
#By Shiroun
#Instructions go Here:

:name_calling  
 def draw_name_actor(x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 236, 32, "Choose a character name.")
  end

  
    if $BTEST == true
      then command_endname
      else 
    end
 if $Script_call_actor = true
  then 
  draw_name_actor(x, y)
   
  elsif 
  $Script_call_actor = false
end
    
  def command_endname
end
 

khmp

Sponsor

Well that error is simply because x and y are not defined when draw_name_actor is called. What are x and y when "draw_actor_name" is called is the question you should be asking yourself? But I think you have other problems here. Let's see, "self", tabbing, use of a symbol, and conditionals.

Ok to start. Tabbing won't lead to a syntax error usually but it helps making code readable. The code looks jumbled albeit short.

"contents" is a Bitmap object of the Window class, I think it is at least, but anyway you use the keyword "self" before it. Yet you have no class or module definition to reference. Meaning this method doesn't exist within an object.

Legal syntax:
Code:
class Awesome
  attr_accessor :x
  def get_x
    return self.x
  end
end

Illegal syntax:
Code:
x = 0
def get_x
  return self.x
end

You're trying to pull off the lower example plus I don't have any idea what you are drawing text to. Next the symbol. I don't tend to use them much so I can't scold you about it. Are you saving an object definition, or a method to it or what? Even if you are you aren't using it so why is it there?

Next those conditionals. The "if then else" statements.

Code:
if $BTEST == true
  then command_endname
  else 
end

You can do that. It is legal and maybe that's your coding style so ignore this next part if you're aware of the other ways you can write an "if then else". But if you only have one outcome or one set of tasks to accomplish based on the comparison. You can toss the "else" because it isn't necessary. That goes the same for the "then".
Code:
if $BTEST
  command_endname
end

Lastly this:
Code:
if $Script_call_actor = true
That code will always be true because it is an assignment and not a comparison. Comparisons are double equals, "==".

Good luck with it shiroun! :thumb:

If you have any other questions regarding this topic just ask.
 

khmp

Sponsor

I'd recommend a custom window to display the name text and perhaps a scene to place it in to handle input. But I couldn't find the typing system by searching this site. Could you provide a link please?
 

khmp

Sponsor

Honestly I'd recommend going over some of scripting tutorials on this forum. Ruby syntax and or Windows preferable. But how about this? Rather than continue this thread with questions and no answers. Read over the code in Window_NameEdit. Any line you can't figure out what's happening just PM me and ask what, why, where etc. But I'll get angry if you send me 20 PMs. So read over the whole thing. Then formulate your questions and pm me. I can't promise I'll be able to answer all the questions but I think I can help you out. Don't forget those tutorials though. I know that with a better understanding of the Ruby syntax. You'll have a lot easier time doing this stuff on your own.

As always good luck with it shiroun! :thumb:
 

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