Adventure Creator original thread

Tips, techniques and tutorials about creation tools.

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Mon, 13May06 06:59

Dakutis wrote:
I have one question, I have 3 different gameVars and I need something like this d = a + b + c where (a,b,c is 3 different gameVars) I need "d", where "d" will be gameVars too, and I use it in other functions and in gameShowScore().

I write something like that:

function calcScore()
{
var d= readVar("a") + readVar("b") + readVar("c");
return d;
}
in score its working but in game functions var d = 0


Hi Dakutis,

I'm not very good at JS myself, but I think I see what is happening. You are making the variable d exist only in the function, and not globally. Since score is output from the funciton, it shows in score, but nowhere else, because the variable does not persist. You would need to make sure d is set into the global variable. Try this:

var calc = readVar("a") + readVar("b") + readVar("c");
setVar("d",calc);
return d;

Wolf.
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Dakutis » Mon, 13May06 07:21

Wolfschadowe wrote:
Dakutis wrote:
I have one question, I have 3 different gameVars and I need something like this d = a + b + c where (a,b,c is 3 different gameVars) I need "d", where "d" will be gameVars too, and I use it in other functions and in gameShowScore().

I write something like that:

function calcScore()
{
var d= readVar("a") + readVar("b") + readVar("c");
return d;
}
in score its working but in game functions var d = 0


Hi Dakutis,

I'm not very good at JS myself, but I think I see what is happening. You are making the variable d exist only in the function, and not globally. Since score is output from the funciton, it shows in score, but nowhere else, because the variable does not persist. You would need to make sure d is set into the global variable. Try this:

var calc = readVar("a") + readVar("b") + readVar("c");
setVar("d",calc);
return d;

Wolf.


Thanks Wolfschadowe, setVar helped, I create other function and now working :)
function calcd()
{
var d = readVar("a") + readVar("b") + readVar("c");
setVar("d",d);
return d;
}
and in score I write only:
function calcScore()
{
var d = readVar("d");
return d;
}
http://dakutisgames.weebly.com/
User avatar
Dakutis
lagoon predator
 
Posts: 116
Joined: Wed, 12Nov07 14:17
Location: Lithuania, Kaunas
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Mon, 13May06 07:29

Alternately, you could skip the setVar and do this:

function calcd()
{
var d = readVar("a") + readVar("b") + readVar("c");
return d;
}

function calcScore()
{
var d = calcd();
return d;
}

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Dakutis » Mon, 13May06 07:46

tlaero wrote:Alternately, you could skip the setVar and do this:

function calcd()
{
var d = readVar("a") + readVar("b") + readVar("c");
return d;
}

function calcScore()
{
var d = calcd();
return d;
}

Tlaero


but without SetVar d = 0 in debug and in the other functions too.
http://dakutisgames.weebly.com/
User avatar
Dakutis
lagoon predator
 
Posts: 116
Joined: Wed, 12Nov07 14:17
Location: Lithuania, Kaunas
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Dakutis » Wed, 13May08 07:26

I have big question.
I need 'random' function. I need something like that:
you puch "Talk" button and then with random help you get 1 of 5 topic. This is possible to do? If yes then how?
http://dakutisgames.weebly.com/
User avatar
Dakutis
lagoon predator
 
Posts: 116
Joined: Wed, 12Nov07 14:17
Location: Lithuania, Kaunas
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Squeeky » Wed, 13May08 08:00

You need two javascript key words: random and switch.

These two links address both of these.
http://www.w3schools.com/jsref/jsref_random.asp (random function)
http://www.w3schools.com/js/js_switch.asp (switch)

Check those tutorials. Simply random generates a 'seed' which you modify by multiplying your upper range. switch is the equivalent of "If this, then..." case is how switch determines the choice.

This certainly is something I'd see tlaero not wanting to add to her "tool", it's unlikely to be of much demand. Besides, it's rather easy to write for a one-off situation. If you have trouble after trying to understand the tutorials then get back here, someone can help further.


This segment, embedded within an HTML page lets you test the random function.
It should offer a blank page on which is a link "Try".
After selecting it you need to use whatever is "Previous Page" on your browser for a further test:

<a href="javascript:randomise()">Try</a>
<script lang="javascript">
function randomise(){
a=Math.floor(Math.random()*5+1);
document.write(a);
}
</script>
Squeaky is clean, I'm just a tad messy!
User avatar
Squeeky
Spirit of the oceans
 
Posts: 4169
Joined: Mon, 08Jan07 00:00
Location: Australia
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Dakutis » Wed, 13May08 11:12

Thanks Squeeky, with numbers I understand, but I need that when you push "Talk" you can go to 1 of 5 different html files. Where I have to write all these html files names?
Exsample, there is talk.html then it have to go random to (talk1.html or talk2.html or talk3.html or talk4.html or talk5.html).
http://dakutisgames.weebly.com/
User avatar
Dakutis
lagoon predator
 
Posts: 116
Joined: Wed, 12Nov07 14:17
Location: Lithuania, Kaunas
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby hrmf » Wed, 13May08 23:59

with numbers I understand, but I need that when you push "Talk" you can go to 1 of 5 different html files. Where I have to write all these html files names?


Here's one idea.

Code: Select all
var possibilities = [ "file1.html", "file2.html", "file3.html", "file4.html" ]; // Filenames don't matter here
var random_index = Math.floor( Math.random() * possibilities.length );
var new_filename = possibilities[random_index];

window.location = new_filename;  // redirect browser
 


To add a new page, you just add another element to the list.
hrmf
great white shark
 
Posts: 25
Joined: Tue, 12Dec11 00:59
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Squeeky » Thu, 13May09 02:38

Dakutis,
I would have to do quite some work to make my proposal (using switch) work, but hrmf gives something that is very neat, and very understandable.
I've included his code in the following. Copy and save it as an HTML page. When you choose the link your browser will report not being able to find "filex.html". Select "previous page" and try again. By repeating this you will see that random pages are not being found. Obviously when you write them you are going to have success.


<head>
</head>
<body>
<a href="javascript:talk();">Talk</a>
<script lang="javascript">
function talk(){
var possibilities = [ "file1.html", "file2.html", "file3.html", "file4.html" ]; // Filenames don't matter here
var random_index = Math.floor( Math.random() * possibilities.length );
var new_filename = possibilities[random_index];

window.location = new_filename; // redirect browser
}
</script>
</body>
</html>

To hrmf, from my position, many thanks for the lesson as I am somewhat of a novice to javascript.
Squeaky is clean, I'm just a tad messy!
User avatar
Squeeky
Spirit of the oceans
 
Posts: 4169
Joined: Mon, 08Jan07 00:00
Location: Australia
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Thu, 13May09 04:39

The code Squeeky and Hrmf wrote is good. Make sure you put it in a function in _game.js though. If you put it in an HTM file and then open that file in AC, it'll remove it.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: A tool to help write "Virtual Date" games

Postby Dakutis » Thu, 13May09 08:29

Thanks to all its working fine.
to Tlaero - yes I write it in _game.js
http://dakutisgames.weebly.com/
User avatar
Dakutis
lagoon predator
 
Posts: 116
Joined: Wed, 12Nov07 14:17
Location: Lithuania, Kaunas
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Sun, 13May12 20:23

Tlaero,

I'm running into a minor issue with Adventure Creator regarding area links for images.

I'm not sure how it happens, but it's probably related to me resizing or moving areas while creating new pages. Somehow AC loses all visibility of the area, so I can't delete it. I don't know if the mapping moves the area out of the image zone, or if it is a 1px by 1px zone, or what, but what ends up happening is that I get a string of pages with an invalid area link, making the border appear on a page.

For an example, if you open n1-bar91-h.htm in BEW, Ver 0.0.9 you will note that it has the yellow border, but no targets. Open AC, and you will also see no targets, but game view will show an entry for area targets. The only way I've found to remove the entry is to manually edit the HTML page.

I doubt there is a way to prevent this from happening because it is likely user error in the first place, but having an option to clear all area entries, similar to the buttons that clear talking table options, could help resolve it.

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Super » Sun, 13May12 21:32

To anyone making one of these games: After having played SITA, I can't help I can't help but wish there was a way to keep trck of all the secrets you've found. I dunno if it's possible since these games are technically a bunch of interlinking web pages instead of a singular program, and thus it may not be able to save an "achievement". But it'd be cool if these games could do that too. for example, BEW seems like it'd benefit greatly from this due to the size it's looking to be. For instance, having an achievement for going all the way in the threesome scene in the bar (so judged by Emily eagerly responding to the kiss) or having her blow you in the bathroom. After all, gamers love collecting things in all of their games XD

Again, dunno if it's possible in these games due to the nature of their existence. Just thought I'd share how much I loved that aspect of SITA and wished more games could have a checklist of all the hidden stuff. Also, if it were possible to save remotely which endings or secrets you've obtained, having an option to replay the ones you've found would be greatly appreciated by many, I'm sure. Just some food for thought for you guys
Super
legend of the South Seas
 
Posts: 545
Joined: Wed, 11Aug24 20:59
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby Wolfschadowe » Sun, 13May12 21:52

I would tend to agree with you Superawesomemans, but there are limitations with a purely browser based game like BEW.

SITA installs and runs an executable on the system, which could be a security risk for some folks, although I'm confident SITA is safe. It does allow for tracking progress, savegame's, and achievements in a reliable fashion because the executable grants access to creating files on the system that are persistent.

While I love SITA, it had some limitations that pulled me out of the game somewhat, for example there are no image targets. I personally find the ability to click on a woman's lips to kiss her more engaging and immersive than selecting "kiss her" from a list of options like in SITA. This is something that I was disappointed to lose in between Arianeb, and SITA, although I may be in the minority there. Not withstanding, I still really enjoy SITA.

The difficulty in save games and achievements in games like BEW, is that all the information is saved in cookies. That means, the first time the player clears browser history and cookies, all progress, savegames, and achievements are lost. I could fairly easily build achievements into the game, and have an achievements page a player could go to, but since they would be non-persistant, it seems more effort than it's worth, and I'd be inundated with complaints from people losing their achievements, which would probably take a lot of the fun out of it for me. For these reasons, BEW will not have an achievement system...although I reserve the right to change my mind on that if there is an easy, reliable way to implement them. [img]images/icones/icon7.gif[/img]

Of course, this is all based on my understanding of browser games, and how AC works. I'm sure Tlaero will correct me if anything I've said is wrong. [img]images/icones/icon13.gif[/img]

Wolfschadowe
User avatar
Wolfschadowe
legend of the South Seas
 
Posts: 559
Joined: Thu, 13Mar21 07:37
Location: West Coast, USA
sex: Masculine

Re: A tool to help write "Virtual Date" games

Postby tlaero » Sun, 13May12 23:12

I think you're both right. We could get most of the way to achievements if I created a second set of variables that aren't affected by loading state. But they'd be stored in cookies and lost if the player cleared his browser cache. That said, the same is true of the current save games, and no one has complained about losing a save. I'll work on it.

Wolf, if you can get me the steps you take to reliably reproduce the lost hit target, I'll investigate.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

PreviousNext

Return to The workshop of creators

Who is online

Users browsing this forum: No registered users and 3 guests

eXTReMe Tracker