Jump to content




CraftOS 1.71 with string.gsub


  • You cannot reply to this topic
2 replies to this topic

#1 biggest yikes

  • Members
  • 573 posts

Posted 05 March 2015 - 10:01 PM

I was messing around with CC a while ago, and I noticed that the following code
local version = os.version()
print(version:gsub("Craft", "Cyan"))
Actually prints out "CyanOS 1.71" instead of the proper result, "CyanOS 1.7" in CC 1.73.
Posted Image
Yet the actual version number is CraftOS 1.7, even with the Lua console..
Posted Image
Can someone explain why this is? I'm not sure if it's a glitch in 1.73 or something, but I find it strange.

EDIT: Turns out it was just because I returned the first and second output instead of just the first. Oops ._.

Edited by Atenefyr, 05 March 2015 - 10:11 PM.


#2 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 05 March 2015 - 10:04 PM

string.gsub returns the changed string and a number of how many matches were replaced. That's where that '1' comes from: it replaces only one match.

#3 biggest yikes

  • Members
  • 573 posts

Posted 05 March 2015 - 10:04 PM

View PostMKlegoman357, on 05 March 2015 - 10:04 PM, said:

string.gsub returns the changed string and a number of how many matches were replaced. That's where that '1' comes from: it replaces only one match.
Oh, I see, my bad :P

Edited by Atenefyr, 05 March 2015 - 10:05 PM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users