room.description = 0
\\in start script
\\room script
if (room.description = 4) {
room.description = room.description - 4
}
\\this is the bit i'm getting wrong. The code below works fine.
room description = room.description + 1
msg ("{if room.description=1:Wow, the code is right!}")
https://msdn.microsoft.com/en-us/library/h6zfzfy7(v=vs.90).aspx
if (xxx1.xxx2 = xxx3) {
msg ("hi")
if (xxx4.xxx5 = xxx6) {
msg ("bye")
}
}
room description = room.description + 1
jaynabonne wrote:I'm not sure what you're trying to do, so I can't say exactly what's going wrong. As HK said, if you want it to be 0, then you can set it to 0.
There is a typo, though, in what you posted:room description = room.description + 1
needs a dot after the first "room" (room.description).
As far as your code in general, the way you have it coded, then:
if room.description is 4, then it will be 1. Otherwise, it will be room.description+1.
As I said, I don't know what you're trying to do, so I can't say whether the code is doing it right or wrong!
(It also seems odd to me to be using "description" as an integer variable, since "description" is the name of the string or script attribute that Quest uses to display the room description. Which means that when the player comes into the room, Quest will just ignore it. Where does the script you showed exist? If it's the room description script, then as soon as you run your game, you set it to an integer 0 and lose the script!)
[Sorry, cross posted.]
<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="count">
<gameid>2e12d5bd-b5e8-4bd4-bbcc-b184f570b340</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<start type="script">
decompression.description = 0
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="south" to="decompression chamber">
<inherit name="southdirection" />
</exit>
</object>
<object name="decompression chamber">
<inherit name="editor_room" />
<description type="script">
if (decompression.description = 4) {
decompression.description = decompression.description - 4
}
// this is the bit i'm getting wrong. The code below works fine.
decompression.description = decompression.description + 1
msg ("{if decompression.description=1:Wow, the code is right!}")
</description>
<object name="decompression">
<inherit name="editor_object" />
<scenery />
</object>
</object>
</asl>
if (compression.description = 4) {
compression.description = 0
}
compression.description = compression.description + 1
if (compression.description = 4) {
compression.description = compression.description - 4
}
compression.description = compression.description + 1
if (player.age => 24) {
player.age = player.age - 4
if (player.age = 20) {
msg ("You're now 20, 4 years younger, than you were at 24")
} else if player.age = 21) {
msg ("You're now 21, 4 years younger, than you were at 25")
} else if (player.age = 22) { // etc etc etc
}
}
I did remember some guy said recently about the script triggering at the same time. If the script is telling the integer to return to zero at the same time it's telling it to add one etc. But surely the engine reads it sequentially?
jaynabonne wrote:I did remember some guy said recently about the script triggering at the same time. If the script is telling the integer to return to zero at the same time it's telling it to add one etc. But surely the engine reads it sequentially?
That poster was a little confused. It had to do with certain UI operations not blocking, not with the actual sequential execution of code.
<function name="Addem" parameters="a,b" type="int">
return(a + b)
</function>
result = Addem(3, 5)
<function name="character_creation_function" parameters="x">
// I'm lazy, and I don't want to write out 'player' lol, so instead I've (temporarily) changed the label of 'player' ( 'alias' String Attribute: quasi-permanent) to 'x' (a temporary Variable just for 'character_creation_function' Function's scripting)
// 'player' -> 'x'
msg ("What is your name?")
get input {
x.alias = result
// conceptually: player.alias = x.alias = result
}
</function>
// I type in for my name: HK
// A later (afterwards) scripting:
msg ("Your name is " + player.alias + ".")
// quest will output: Your name is HK.
<function name="function_1" parameters="self,enemy">
msg (self.alias) // outputs: HK
msg (enemy.alias) // outputs: zukor
function_2 (self,enemy)
</function>
// self -> abc // conceptually: player = self = abc
// enemy -> zyx // conceptually: orc = enemy = zyx
<function name="function_2" parameters="abc, zyx">
msg (abc.alias) // outputs: HK
msg (zyx.alias) // outputs: zukor
function_3 (abc, zyx)
</function>
// hopefully you get the transition'ing concept now:
// abc -> red // conceptually: player = self = abc = red
// zyx -> blue // conceptually: orc = enemy = zyx = blue
<function name="function_3" parameters="red,blue">
msg (red.alias) // outputs: HK
msg (blue.alias) // outputs: zukor
</function>
foreach (temporary_Variable, Object_name.List_name)
if (temporary_Variable.alias = "Silver") {
temporary_Variable.eat_ice_cream
} else if (temporary_Variable.alias = "HK") {
temporary_Variable.run_laps
}
}
Silver wrote:Although I'm just curious really. I'm learning stuff on a need-to-know basis. Although the more I learn, I realise I needed to know it much earlier than I thought.
That's why I'm pleased I haven't galloped ahead with my game. It would have been a nightmare I think.
compression.description = compression.description + 1
if (compression.description = 4) {
compression.description = 1
}
if (room.description = 4) {
room.description = 0
}
room description = room.description + 1
msg ("{if room.description=1:Wow, the code is right!}")
\\room script
if (room.description = 4) {
room.description = 0
}
room description = room.description + 1
on ready {
msg ("{if room.description=1:Wow, the code is right!}")
}
jaynabonne wrote:How do you know it counted one, two, three, missed a beat, etc? I only see it outputting when value is 1.
msg ("{if compression.description=1:string1}{if compression.description=2:string2}{if compression.description=3:string3}")
HegemonKhan wrote:is this your code that is not working?if (room.description = 4) {
room.description = 0
}
room description = room.description + 1
msg ("{if room.description=1:Wow, the code is right!}")
this should be working... I think...
unless it is a 'string' vs 'int' issue, or maybe you need to make it wait first (this is likely wrong ~ ie: not the case):\\room script
if (room.description = 4) {
room.description = 0
}
room description = room.description + 1
on ready {
msg ("{if room.description=1:Wow, the code is right!}")
}
decompression.description = 0
<function>
decompression.description = decompression.description + 1
if (decompression.description = 4) {
decompression.description = 0
}
if (decompression.description = 0) {
msg ("0") // this will never get outputed
} else if (decompression.description = 1) {
msg ("1")
} else if (decompression.description = 2) {
msg ("2")
} else if (decompression.description = 3) {
msg ("3")
} else if (decompression.description = 4) {
msg ("4") // this will never get displayed
}
// loop
</function>
decompression.description = 0
<function><![CDATA[
if (decompression.description > 4) {
decompression.description = 0
}
if (decompression.description = 0) {
msg ("0")
} else if (decompression.description = 1) {
msg ("1")
} else if (decompression.description = 2) {
msg ("2")
} else if (decompression.description = 3) {
msg ("3")
} else if (decompression.description = 4) {
msg ("4")
}
decompression.description = decompression.description + 1
// loop
]]></function>