maxorator

  • VC:MP Developer
  • Posts: 153
Re: Scripting challenges!
« Reply #30, on June 14th, 2015, 07:43 PM »Last edited on June 14th, 2015, 08:08 PM
Here we go...
(click to show/hide)
Code:
http://pastebin.com/tum2Xgj4
Sprites:
http://imgur.com/a/tcdaz
Filenames for them should be board.png, cellx.png and cello.png.

This is actually my first script in Squirrel which is not just a few lines of code to test some feature.

Oh, forgot to mention. I was too lazy to mess with relative positioning so it just places them so it looks good on 1920x1080 resolution. Anything too much smaller and the board will probably be somewhere off-screen.

Server currently running this script is at: maxorator.empiro.co.uk:8192

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,193
Re: Scripting challenges!
« Reply #31, on June 15th, 2015, 02:28 PM »
@maxorator
I have tested your Tic-Tac-Toe with @Skirmant, and I enjoyed it alot ! 8)
I like that you don't freeze the player, in this way the TTT being a cool bonus to the normal gameplay.

Unfortunately, after the first game, it started to be buggy...
After I started the second/third game, and played a while, I got an unexpected message: game ended and a player was selected to be the winner.

Also, I have a little suggestion: set the first one who plays to be random.
Was kinda annoying when I was challenging Skirmant and he was always the first one. :D

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,757
Re: Scripting challenges!
« Reply #32, on June 15th, 2015, 03:57 PM »
Quote from Stormeus on June 14th, 2015, 05:45 PM
Quote from NE.CrystalBlue on June 14th, 2015, 03:58 PM
Quote from S.L.C on June 14th, 2015, 03:48 PM
Quote from NE.CrystalBlue on June 14th, 2015, 01:31 PM
This requires CreateSprite which is not yet compiled...
What do you mean it's not yet compiled? Have you created a sprite before?

Code: [Select]
.Func(_SC("CreateSprite"), CreateSprite, 8, _SC("tsiiiini"))
Who said we load the whole module? We just load squirrel... Pure and native support only
... sprites are pure and native to Squirrel. End of discussion.
They are pure and native to VCMP. End of discussion.

Honey

  • Full Member
  • Posts: 135

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
.

Stormeus

  • VC:MP Developer
  • oh god how did i get here im not good w computer
  • Posts: 1,128
Re: Scripting challenges!
« Reply #35, on June 15th, 2015, 05:28 PM »
Quote from NE.CrystalBlue on June 15th, 2015, 03:57 PM
Quote from Stormeus on June 14th, 2015, 05:45 PM
Quote from NE.CrystalBlue on June 14th, 2015, 03:58 PM
Who said we load the whole module? We just load squirrel... Pure and native support only
... sprites are pure and native to Squirrel. End of discussion.
They are pure and native to VCMP. End of discussion.
The purpose of this thread is diverse. It doesn't just entail completing a task using the default Squirrel natives. What SLC has provided is a real-world example of a script that people could adopt in the future, and is challenging scripters to try to construct it, which, IMO, is far more interesting than the abstract challenges that are less relevant to this community (but still do a good job enforcing syntax, which some people still fail to do).

If you have an issue with this thread not being limited to the Squirrel core libraries, you're welcome to leave. You can send any further criticism to my or SLC's PM inbox, but I don't want to hear another word of it in this thread, because we're already venturing off topic.

dEaN

  • Newbie
  • I wouldn't know a good script if it bit me
  • Posts: 45
I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,757
Re: Scripting challenges!
« Reply #37, on December 19th, 2016, 11:43 AM »
I know this is an 18-month bump, but these were quite nice. Do you have any plans on continuing them?

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: Scripting challenges!
« Reply #38, on December 19th, 2016, 04:32 PM »
Quote from EK.CrystalBlue on December 19th, 2016, 11:43 AM
I know this is an 18-month bump, but these were quite nice. Do you have any plans on continuing them?
If you find one at a level close to the average vcmp scripter and at the same time to actually be challenging. Then feel free to post it here and I'll put it into the first post.

All I've got so far is "print("hello world!");" :P

Joking aside, I know these were fun, but it's hard to also keep it challenging and simple enough for others to follow. That being said, anyone is free to come up with ideas.

The only rule is that they must not require a lot of coding. The real challenge usually must be to keep the code to a minimum.

Also, I'll have to start individual topics because having one huge topic might get a little messy.
.

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,212
Re: Scripting challenges!
« Reply #39, on December 21st, 2016, 11:39 AM »
Okay here is a little challenge if you would like to take.

Challenge: Create a simple table which does not throw an index does not exist error if you try to add any value in an undefined index.

Probably too simple for someone or too hard for someone else but meh keeping it short and less stressful as SLC said above :D

jWeb

  • Full Member
  • Posts: 145
Re: Scripting challenges!
« Reply #40, on December 21st, 2016, 11:56 AM »
(click to show/hide)
Code: [Select]
local mm = {
    _get = function(k) { return null; }
    _set = function(k, v) { this.rawset(k, v); }
};

local person = { name = "Bawss" }.setdelegate(mm);

print(person.name);
// Do not exist (yet)
print(person.age);
print(person.city);

// Note the '=' and not '<-'
person.age = 37;
person.city = "Candyland";

print(person.name);
// Now they exist
print(person.age);
print(person.city);

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,757
Re: Scripting challenges!
« Reply #41, on December 21st, 2016, 03:27 PM »
(click to show/hide)
t1 <- {a=1, b=2};
Usage:
(click to show/hide)
try
{
    t1["d"] = t1["c"];
}
catch (e) {}

Serious usage:
(click to show/hide)
t1["d"] <- 3;

KAKAN

  • Wiki Contributor
  • Posts: 3,338
Re: Scripting challenges!
« Reply #42, on December 21st, 2016, 04:06 PM »
Quote from EK.CrystalBlue on December 21st, 2016, 03:27 PM
...
There's a difference between your code and doom's challenge. Anyone can insert a new slot( using the '<-' sign ). The question was completely different. Try to understand the question again.
oh no

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,757
Re: Scripting challenges!
« Reply #43, on December 22nd, 2016, 05:58 AM »
Quote from KAKAN on December 21st, 2016, 04:06 PM
Quote from EK.CrystalBlue on December 21st, 2016, 03:27 PM
...
There's a difference between your code and doom's challenge. Anyone can insert a new slot( using the '<-' sign ). The question was completely different. Try to understand the question again.
Well... I can't now, since after posting my reply, I read jWebs answer.

Anik

  • Sr. Member
  • Posts: 355
Re: Scripting challenges!
« Reply #44, on April 12th, 2017, 08:21 AM »
Here's a little challenge from me.

Challenge : Write a program that uses a numeric variable and displays that number of rows of *, with one * in the first row, two in the second row, and so on. For each row, the asterisks are preceded by the number of '.' needed to make all the rows display a total number of characters equal to the number of rows.

A sample run would look like this:
Number of rows :  5
....*
...**
..***
.****
*****
Number of rows :  7
......*
.....**
....***
...****
..*****
.******
*******