Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: splice alternative? (for randomizer duplicates)  (Read 9170 times)

0 Members and 1 Guest are viewing this topic.

anheric

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
    • View Profile
splice alternative? (for randomizer duplicates)
« on: November 24, 2011, 12:13:57 PM »

I just found that .splice method is not supported (implemented) in WME
anyone knows any alternative to splice i can use ?

Just to be clear I didnt research much about scripting in WME and i dont even understand javascipt yet..
I just need a randomizer for my array

so this is my array(s)
Code: [Select]
var hiddenItems = new Array();
hiddenItems[0] = "Book1";
hiddenItems[1] = "Book2";
hiddenItems[2] = "face";

var hiddenItemsName = new Array();
hiddenItemsName[0] = "Pink Book";
hiddenItemsName[1] = "Blue Book";
hiddenItemsName[2] = "Face of a girl";
and here is my code so far:
Code: [Select]
var d = new Array(1,2,3);
var e=0;
for (var b=0; b<3; b=b+1)
{
var editit = "editor" + d[e]; //find editor --- all my editors are named like: "editor1", "editor2" etc..
var one= hidden_object.GetControl(editit); //take editor
one.Caption = hiddenItems[e] ; //add to editor caption
one.Text = hiddenItemsName[e] ; //add to editor text
e= e+1;
}
I needed to add something like this in my loop :
Code: [Select]
variable = Math.floor(Math.random() * d.length);
value = variable2.splice(variable,1)[0]; // remove the selected number from the array and get it in another variable
so i have no duplicates but i get syntax error at .splice line..

im sorry for posting this here(i understand this is basics and i should educate myself more) but im stuck at this for days now..
Logged

jackslawed

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 23
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #1 on: November 24, 2011, 04:01:25 PM »

Hey Anheric... still trying to create that HOG?

I said the other day that I was experimenting... I did some more today, and now have a basically functioning hidden object game template. It functions fine, there are colored balls instead of hidden objects, but that's simply waiting for different graphics. The whole scene needs only four scripts and an include; with that you should be able to hide an infinite number of objects.

I'm always asking stupid questions about programming, but since I have no experience, sometimes I am good at finding simple answers (the code is probably very ugly)

Anyway, take a look at the script and things, and maybe we can make it better. It's not technically the answer to your splice question, but it should be useful. Link here:

http://www.miskatonicgame.com/HOG.zip

Let me know if it works for you... there are some other features I'd like to add.
Logged

anheric

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #2 on: November 24, 2011, 06:49:37 PM »

Hey! wow the project you gave me works perfectly!
I didn't know you made a full game! looks very nice, congrats :)

Although I don't understand most parts of your code, it looks clean and tidy!
Its very useful and educating, thank you so much for sharing

I have a few ideas
1. we could make the list of "items to find" visible all the time (like most HOG nowdays)
2. maybe we should have all the items visible; just few of them to be clickable. take a look at this :http://i1-mac.softpedia-static.com/screenshots/Mystery-Case-Files-Return-to-Ravenhearst_2.jpg
   here you can see a bunch of items but you only have to find 12 of them. (each time you start a brand new game you get random selection of items)
and 3. the game is awesome so far!

thanks for the help once again jackslawed!  :D
Logged

jackslawed

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 23
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #3 on: November 24, 2011, 08:29:54 PM »

I'm not really making a full game, just experimenting. But I guess that's all that's needed.
Feel free to take the code/example project completely and use it for whatever you want commercially or for fun (and anyone else using this forum).

Regarding your ideas:
1. In this case, I think would best to use a transparent window (with no background image), and then simply overlay the static text controls on a permanent entity. The trick would be updating the text without screwing up... I can see a few problems might occur there.
2. This is really simple, requires no more coding; simply use region entities instead of sprite entities! Everything else will work as before.

Anyway, I'm going to fiddle around later on... it could be useful to have a template available for anyone who wants to use WME for hidden object games. These should work in WME Lite as well, so the iOS option is available as well as windows. It give me a distraction to avoid getting on with my real work too....
Logged

anheric

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #4 on: November 24, 2011, 10:23:11 PM »

I was talking about miskatonic , congrats on that  ;)

on the other hand, this will teach alot any beginner that's making a hidden object game
Logged

anheric

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #5 on: November 25, 2011, 02:33:46 PM »

I managed to do the changes I mentioned earlier:

1. Make the list window visible at all time
2. Make all items visible - just some of them are actually "hidden objects"
- and some other minor changes plus I removed one script because its not needed now, you should check it out

the code is definitely looking more complicated though I commented almost everything
The file : http://db.tt/fjlU6XxZ (HOG.zip)

The deal is, the way i randomized the items, is kinda hackish... but for now it works
Logged

jackslawed

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 23
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #6 on: November 27, 2011, 05:26:54 PM »

So here's my new two cents.I feel like your code was unnecessarily complicated... you can essentially use the same code as before, replacing the "Active" property with "Interactive". That removes the concerns you noted in the comments. I do like the totalObjects global variable, good idea! I commented out the extra loop in sceneinit... it can probably be completely deleted. There was also a problem with inert items playing the click sound when clicked... that is fixed now.

I also "skinned" it after watching a youtube of Ravenhearst. I added a menu button and a hint button... not sure how the hint system usually works in HOGs, you can see how mine works. Finally, I added an animation to the itemclick script.

http://dl.dropbox.com/u/43588217/HOGV3.zip

Let me know what you think.
Logged

shuin

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 51
    • View Profile
Re: splice alternative? (for randomizer duplicates)
« Reply #7 on: December 14, 2011, 12:38:51 AM »

@jackslawed: your template is pretty great especially for people that want to make HOGs. I think you should make a new thread in the 'Scripts, plugins, utilities, goodies' section and share the template with the Wintermute community. It's kind of hidden in this topic (pun intended  ;D )

So yeah, great stuff. It really deserves a thread of its own, with all the technical explanations (or if it's well commented just a brief description) and the archive of the template.  ::rock
Logged
Untitled project status: production
 

Page created in 0.046 seconds with 20 queries.