Simple Item Renaming Code

#1
Before you say anything, I want to give full credit to juanjpro for writing the code presented here. Send your thank you messages and desperate selfies to him.

Hey! Are you bad at making your own code in Blitz3D? Are YOU desperate to rename the item in SCP:CB without wasting your weeks and/or months renaming the Gas Mask to :EXPUNGED:

FEAR NOT! Here is a quick and simple code that will make it BEYOND easy to turn "Origami" into "Little friend"

Alright, lets get to it!

INSTRUCTIONS
SEE THAT?! I made that word as fucking huge as I can to grab your attention, especially you; "TL:DR"s.

Alright, enough bullshit.

Step 1:
In Main.bb, put this anywhere you want as long as it doesn't conflict with other existing functions. (Preferably, put it at the very top.)

Code: Select all

Function InvName$(inputName$)
   Select inputName
      Case "Some SCP-420-J" ;item's old name (case-sensitive)
         Return "Weed" ;item's new name
      ;add some more cases here
      Default
         Return inputName
   End Select
End Function
BUT WAIT!
You're not done yet. Just this piece of code alone won't work if you don't do step 2.

Step 2:
Find this somewhere in Main.bb

Code: Select all

Color 0,0,0
Text(x + width / 2 + 1, y + height + spacing - 15 + 1, Inventory(n)\name, True)                     
Color 255, 255, 255   
Text(x + width / 2, y + height + spacing - 15, Inventory(n)\name, True)
And replace it with this:

Code: Select all

Color 0,0,0
Text(x + width / 2 + 1, y + height + spacing - 15 + 1, InvName(Inventory(n)\name), True)                     
Color 255, 255, 255   
Text(x + width / 2, y + height + spacing - 15, InvName(Inventory(n)\name), True)
And that's it! Feel free to use this code as you wish. juanjpro made this, so again, go thank him.
STEAM
## LOG OFF.

Re: Simple Item Renaming Code

#3
Nice simple code, juanjpro, but surely there is a better way to rename items?

For example, you could change the main item function to accept another parameter, which is the display name.
Add an if that basically checks if the display name parameter is there, and if it isn't then set it to the default name.
EDIT: Declare the display name in the inventory object :P
For any items you wish to change the name of, set the display name parameter.
Then just edit the Inventory(n)\name to the display name variable.

This way, the program doesn't have to look for the right display name every time it is needed, as it will already be set in the inventory. Slight optimization ftw :P
SCP - Box of Horrors v0.8.0b
Twitter
Github Profile

Re: Simple Item Renaming Code

#4
InnocentSam wrote:Nice simple code, juanjpro, but surely there is a better way to rename items?

For example, you could change the main item function to accept another parameter, which is the display name.
Add an if that basically checks if the display name parameter is there, and if it isn't then set it to the default name.
EDIT: Declare the display name in the inventory object :P
For any items you wish to change the name of, set the display name parameter.
Then just edit the Inventory(n)\name to the display name variable.

This way, the program doesn't have to look for the right display name every time it is needed, as it will already be set in the inventory. Slight optimization ftw :P
I think I will make this code a bit performed into my Mod (like InnocentSam suggested). But still, nice code juan :).
Image

Re: Simple Item Renaming Code

#6
CLgaming wrote:Are YOU desperate to rename the item in SCP:CB without wasting your weeks and/or months renaming the Gas Mask to :EXPUNGED:
Is it really that hard to just find every instance of the word 'Gas Mask' being used in the Items.bb and MapSystem.bb then rename it to something else?

Also,
CLgaming wrote:
Quote wrote:FEAR NOT!
Quote wrote:BEYOND
Quote wrote:fucking huge
CAPITALIZATION AND UNNECESSARY STYLING REALLY EMPHASIZES YOUR POINTS
Last edited by CommanderMark on Wed Feb 25, 2015 2:30 pm, edited 1 time in total.

Re: Simple Item Renaming Code

#7
CommanderPro100 wrote:
CLgaming wrote:Are YOU desperate to rename the item in SCP:CB without wasting your weeks and/or months renaming the Gas Mask to :EXPUNGED:
Is it really that hard to just find every instance of the word 'Gas Mask' being used in the Items.bb and MapSystem.bb then rename it to something else?
Actually it's not that hard, but I could use it for some things such as the COOP I plan to integrate into my mod (the items must be correctly sent/resent from/to the server and this would make it easier for the server). But for a simple mod that's like changing item names you could just edit all instances by yourself.
BTW: I think I would also rewrite the code that every item has it's own item ID (very similar to Minecraft). That would be very easy for the Server to handle items (just an Int value rather than two Strings). But I will use this function as a base for my item detection code (it's detecting the ItemID and returns the "tempname" and the displaying name of each item).
Image
cron