Jump to content


Photo
- - - - -

Custom Text Script


  • Please log in to reply
5 replies to this topic

#1 turtlefan

turtlefan

    Hockey Goalie

  • New Member
  • 264 posts

Posted 25 July 2009 - 08:09 AM

  • Title: Custom Text Script
  • Description: This will create custom text on your screen using your own font, no installing new fonts required.
  • GM Version: GM7, GM6 and GM5, possibly older versions too
  • Registered: No
  • File Type: .gmk
  • File Size: 44.0kb
  • File Link: Download Link
Additional Info

I got the Idea for this from an RPG Textbox example that was on the GMC a while back. I don't see it anymore and forget who the creator was. In the past I adapted the code from that example to create standing text on the screen. Recently I started from scratch and made my own text engine based off of the Textbox example. I did edit one script from the Texbox example, the script Letter, was taken from the other example and edited to fit my new scripts. Even though I did have to edit it, I do not want to claim that script as my own. If you were the orignal creator of that script PM me and I will either credit you for the script or rewrite it myself if you have changed your mind about letting others use it.

Other than that I think the engine is fairly simple to use, just edit the text sprites to your liking.

This example includes,
- Drawing custom test
- Mutliple text lines on one screen
- Text positioning
- Text wrapping

Credit is not needed, but would be nice. I would also like to see your game if you use this, so send me a link if you want!

Edited by turtlefan, 14 August 2011 - 05:20 PM.

  • 0
Game Maker 5.3 User...

Dereks Challenge 2: My Work In Progress... Last Updated August 2 2009, Check it out at the links below!

YOYO Games Link: Click Here
GMC Thread Link: Click Here

Need to create your own custom text in your game? Check out my Custom Text Engine here, Custom Text Engine

#2 turtlefan

turtlefan

    Hockey Goalie

  • New Member
  • 264 posts

Posted 03 August 2009 - 01:49 AM

Okay, so the suggestion was made on the YOYO Games site to make this so that instead of redrawing the text every step, which uses up a lot of the CPU, it simply creates a letter object instead. This uses about have the CPU space as the previous example, however both work. I guess that advantage to drawing the text is that a string can be changed much easier. Here is the new scripts:

Text Script:
text = argument0 // The text to be written
font = argument1 // The "font" to be used
xpos = argument2 // x position of the text
ypos = argument3 // y position of the text
width = argument4 // Width restriction of the text
firsttime = argument5 // Determines whether this is the first letter being drawn or not

// This script is what draws the text
if firsttime != 0 //If it is the first time through the script
	{length = string_length(text) i = 0 xx = argument2} //Get the string length set i to zero, xx is the starting x point for text wrapping

if firsttime = 0 
	{length = argument6 i = argument7 xx = argument8} // get length, i and xx variables from the Text_Script function below

if length != 0 //If there is still text to be written
	{
	i+=1 //i will be used to add one to the current string position
	length -=1 // Subtracts 1 from the string lentgh  - Used to tell how much is left to be written
	letter = Letter(string_char_at(text,i)) //Calls the Letter script to identify the character being written
	global.letter = real(letter)
	if font = "font1" {instance_create(xpos,ypos,fontone)} //Draws the character - uses the object fontone
	if font = "font2" {instance_create(xpos,ypos,fonttwo)} //Draws the character - uses the object fonttwo
	xpos +=7 //Moves the x position over for the next letter
	}

if real(letter) = 52 // If Letter returned a space
	{
	global.word = Spacing(argument0,i,1) //Call the Spacing script
	newlength = real(global.word*7) // Spacing script will return the length of the new word

		if newlength + xpos > argument4 {xpos = xx ypos +=20} // Checks the length of the next word and puts it on a new line if needed

	}


if length != 0 //If there is still text left to be written 
{Text_Script(argument0,argument1,xpos,ypos,argument4,0,leng
th,i,xx)//Do the textsript again for the remaining letters
exit;}//There is no need to change any arguments in the function above

if length = 0 //If no letters remain you're done and so is the script!
{exit;}


To call the Text Script, use it the same way as in the other version, just substitute, "font1" or "font2" in for argument2.

Text_Script("turtlefan's Custom Text Engine","font1",136,32,500,1)

With this new version you also have to create objects for your text, named "fontone" , "fonttwo" etc...
Give these objects the sprite of your letters, and place this code in the create event:

image_single = real(global.letter)

This new version can call the script from any event, which should use up less of your CPU. That should be it, hope someone finds this useful.

turtlefan

Edited by turtlefan, 03 August 2009 - 08:19 PM.

  • 0
Game Maker 5.3 User...

Dereks Challenge 2: My Work In Progress... Last Updated August 2 2009, Check it out at the links below!

YOYO Games Link: Click Here
GMC Thread Link: Click Here

Need to create your own custom text in your game? Check out my Custom Text Engine here, Custom Text Engine

#3 jimn346

jimn346

    GMC Member

  • GMC Member
  • 422 posts

Posted 15 August 2009 - 03:29 AM

Awesome! It doesn't need pro!
  • 0
Posted Image

#4 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 14 August 2011 - 07:29 PM

Nyc....but doesn't work for me...
  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#5 Fat Kid In Your Fridge

Fat Kid In Your Fridge

    GMC Member

  • GMC Member
  • 85 posts
  • Version:GM:Studio

Posted 30 August 2011 - 04:04 PM

Awesome! It doesn't need pro!


Yeah, but if you DO have pro, just use the function font_add_sprite(...) Posted Image
  • 0

Wow.


#6 jimn346

jimn346

    GMC Member

  • GMC Member
  • 422 posts

Posted 31 August 2011 - 01:17 AM

Awesome! It doesn't need pro!


Yeah, but if you DO have pro, just use the function font_add_sprite(...) Posted Image

Posted 14 August 2009 - 10:15 PM

You bumped an old topic. I actually have pro now. :P
  • 0
Posted Image