dMZX Forums: "What's the command that does X" questions - dMZX Forums

Jump to content

  • (8 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

"What's the command that does X" questions Post them here.

#181 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 08 January 2009 - 11:15 PM

I don't know what you mean about the manual saying copy is slow, but it's not going to be slower than those other solutions.
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#182 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 09 January 2009 - 12:36 AM

I always thought the manual was more warning against copy # # # # (or the more general copy block) as a way of copying the robot the command is run from. This has been stabilized, I think, but at least at one time it was an unstable operation that could corrupt your code. It's certainly not a matter of speed, anyway, and I'm pretty sure the manual doesn't indicate it is. But if you can find somewhere that it does, please point it out so we can correct it. And the text in the "robotic uses to avoid" that discusses it could probably use some clarification beyond "don't do this, do that."

"im in ur database, droppin ur t4blez"
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#183 User is offline   Great Knight 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 06-October 08
  • Gender:Male

Posted 09 January 2009 - 11:07 AM

To Pyro1588: Ah, yes, that should work for me hopefully. I create a clone next to the original Robot, then send a message to the clone to become a Fireball. Thanks dude, I'll be sure to check it out on the game I'm currently creating. (I need this code to make a boss.)
0

#184 User is offline   Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,966
  • Joined: 12-October 00
  • Gender:Male

Posted 09 January 2009 - 08:19 PM

I've removed the subsection in the "bad practices" area. It may be weird practice to use COPY # # # # when there's Robot-specific versions around, but now that its action deviates from the Robot-specific commands and starts a copy at the first line, there's really no reason to be wary of using the command that way. Even before, it had its uses, like I mentioned in the help file.
angelic stream - shed sanguine - ill-adapt - avis - para/lyser - renaissance - dead tangent - phosphene blur - birth breeds death - ________ - painted glass - lagniappe

<Exophase> HES STEALING MAH AIRSHIP!!!!!!11111111
0

#185 User is offline   Hoof 

  • "i surpose iritiation bastard covers me also." -Scorch
  • PipPipPip
  • Group: Members
  • Posts: 326
  • Joined: 26-November 05
  • Gender:Male
  • Location:Pittsburgh, PA

Posted 14 January 2009 - 12:03 AM

is there a way to activate/deactivate "fire burns forever" through robotic?
.hoof.
0

#186 User is offline   nooodl 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 735
  • Joined: 28-October 06
  • Gender:Not Telling
  • Location:Belgium

Posted 18 January 2009 - 01:22 PM

Hoof, on Jan 14 2009, 01:03 AM, said:

is there a way to activate/deactivate "fire burns forever" through robotic?

"teleport player" to a different board with that setting switched on/off respectively, I guess.
0

#187 User is offline   zzo38 

  • Registered members
  • PipPipPip
  • Group: Members
  • Posts: 446
  • Joined: 16-May 08
  • Gender:Not Telling

Posted 11 December 2009 - 06:47 AM

Hoof, on Jan 13 2009, 04:03 PM, said:

is there a way to activate/deactivate "fire burns forever" through robotic?
Probably best is something like this (but it really isn't perfect):
:1
wait 1
change c08 Floor p?? c00 Fire p??
goto "1"
:0
wait 1
change c08 Floor p?? c08 CustomFloor pb0
goto "0"

(unless you use PZX mode, in which case there are other ways)

This post has been edited by zzo38: 11 December 2009 - 06:58 AM

0

#188 User is offline   ThDPro 

  • Brontosaurus-Sea-slug; Gooey and phallic
  • PipPipPipPip
  • Group: Members
  • Posts: 718
  • Joined: 03-December 06
  • Gender:Male
  • Location:Portland, OR

Posted 11 December 2009 - 07:07 AM

zzo38, on Dec 10 2009, 10:47 PM, said:

Probably best is something like this (but it really isn't perfect):
:1
wait 1
change c08 Floor p?? c00 Fire p??
goto "1"
:0
wait 1
change c08 Floor p?? c08 CustomFloor pb0
goto "0"

Uhhhh....
Wut?

This post has been edited by ThDPro: 11 December 2009 - 07:07 AM

original soundtracks
Better Than Nothing - DOMINATION - Commander Keen: Heroes Lost - Welkin - A Confectioner's Recipe - random ThDPro music stuff
<Risu21121> if you're not going to make a good game, you might as well make a blatantly racist one.
<Kuddy> Testicles.
"Where are my folder?" - KKairos
0

#189 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,943
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 11 December 2009 - 11:51 AM

The idea is that fire, when it burns out, burns to c08 Floor (if you've got it set to 'fire burns to ash' or whatever it is), so if you keep changing c08 floor to fire again, you've got fire burning forever as long as long as that robot is running. Since you can stop and start that loop at will, that's basically toggling 'fire burns forever'.
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#190 User is offline   ThDPro 

  • Brontosaurus-Sea-slug; Gooey and phallic
  • PipPipPipPip
  • Group: Members
  • Posts: 718
  • Joined: 03-December 06
  • Gender:Male
  • Location:Portland, OR

Posted 11 December 2009 - 05:42 PM

Lancer-X, on Dec 11 2009, 03:51 AM, said:

The idea is that fire, when it burns out, burns to c08 Floor (if you've got it set to 'fire burns to ash' or whatever it is), so if you keep changing c08 floor to fire again, you've got fire burning forever as long as long as that robot is running. Since you can stop and start that loop at will, that's basically toggling 'fire burns forever'.

Wow... I feel kinda silly not having figured that one out... I think I read customfloor when it said floor. My mind is playing tricks on me!!

This post has been edited by ThDPro: 11 December 2009 - 05:42 PM

original soundtracks
Better Than Nothing - DOMINATION - Commander Keen: Heroes Lost - Welkin - A Confectioner's Recipe - random ThDPro music stuff
<Risu21121> if you're not going to make a good game, you might as well make a blatantly racist one.
<Kuddy> Testicles.
"Where are my folder?" - KKairos
0

#191 User is offline   Hoof 

  • "i surpose iritiation bastard covers me also." -Scorch
  • PipPipPip
  • Group: Members
  • Posts: 326
  • Joined: 26-November 05
  • Gender:Male
  • Location:Pittsburgh, PA

Posted 11 December 2009 - 05:51 PM

Answers my question. Now if only I could remember why I asked it to begin with...
.hoof.
0

#192 User is offline   Padz 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 398
  • Joined: 02-October 02
  • Gender:Male
  • Location:England IOW

Posted 11 December 2009 - 07:17 PM

Hoof, on Dec 11 2009, 05:51 PM, said:

Answers my question. Now if only I could remember why I asked it to begin with...


Hahahaha, I thought this post was coming.
He who has not faced death can never understand life
0

#193 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,943
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 11 December 2009 - 11:11 PM

Oh nooodl, you card. Oh zzo, you ...... even more of a card.
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#194 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 12:34 AM

Looks like no one has replied here for ages, but this seems to be where I'm supposed to ask so...

I am making a game where I need a robot that refers to enemy robots with a send command to differentiate between enemies, despite them having the same name. I tried to figure out how to use the ROBOT_ID robot counters but they seem to be useless in this regard. If only I could have a robot rename itself when the player touches it, all my problems would be solved, but I cant seem to find a "rename self" type command???
0

#195 User is offline   Hoof 

  • "i surpose iritiation bastard covers me also." -Scorch
  • PipPipPip
  • Group: Members
  • Posts: 326
  • Joined: 26-November 05
  • Gender:Male
  • Location:Pittsburgh, PA

Posted 07 June 2016 - 12:45 AM

MicMotorhead, on 06 June 2016 - 08:34 PM, said:

Looks like no one has replied here for ages, but this seems to be where I'm supposed to ask so...

I am making a game where I need a robot that refers to enemy robots with a send command to differentiate between enemies, despite them having the same name. I tried to figure out how to use the ROBOT_ID robot counters but they seem to be useless in this regard. If only I could have a robot rename itself when the player touches it, all my problems would be solved, but I cant seem to find a "rename self" type command???


It sounds to me like you're looking for a way to rename the robot with robotic.

From the help:

. "@string"

If a comment's string begins with a @, then the rest of the
string becomes the new name for the Robot. For example,
"@Hiya" would name the Robot "Hiya". This clips at the first
14 characters of the string; for example, . "@Robothasanewname"
would cut off and rename the Robot "Robothasanewna".

.hoof.
0

#196 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,943
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 07 June 2016 - 01:55 AM

You can also send to a robot ID using this trick (where RobotID is a counter containing the robot id you want to send to):

send at "r&RobotID&.thisx" "r&RobotID&.thisy" "label"


This won't let you send to the global robot though, as it's not on the board and reports back coordinates -1,-1. You can always have special handling for the global robot if necessary (it always has robot id 0)
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#197 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 02:26 AM

Hoof, on 07 June 2016 - 01:45 AM, said:

It sounds to me like you're looking for a way to rename the robot with robotic.

From the help:

. "@string"

If a comment's string begins with a @, then the rest of the
string becomes the new name for the Robot. For example,
"@Hiya" would name the Robot "Hiya". This clips at the first
14 characters of the string; for example, . "@Robothasanewname"
would cut off and rename the Robot "Robothasanewna".



Thanks! That did the job :(
Now my game actually sort of works!

This post has been edited by MicMotorhead: 07 June 2016 - 02:30 AM

0

#198 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 02:28 AM

Dr Lancer-X, on 07 June 2016 - 02:55 AM, said:

You can also send to a robot ID using this trick (where RobotID is a counter containing the robot id you want to send to):

send at "r&RobotID&.thisx" "r&RobotID&.thisy" "label"


This won't let you send to the global robot though, as it's not on the board and reports back coordinates -1,-1. You can always have special handling for the global robot if necessary (it always has robot id 0)


I'll try playing around with that too. I read the Robot related counters section of the built in help file but didn't get much out of it.
This bit of code you're suggesting sort of makes sense to me (not a programmer by any means), so I'll try and play with it and see what I get out of it :(
0

#199 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 07 June 2016 - 11:58 AM

Dr Lancer-X, on 06 June 2016 - 09:55 PM, said:

This won't let you send to the global robot though, as it's not on the board and reports back coordinates -1,-1. You can always have special handling for the global robot if necessary (it always has robot id 0)


Based on the description of the problem it sounds like MicMotorhead is trying to distinguish a bunch of copy-pasted enemies from some external code, trying to figure out which one the player touched. So the global robot doesn't really apply here. Plus, if you're going to have a global robot, it's probably going to have a unique name like "global" and perform a unique function, so addressing it by name shouldn't be a problem.

@MicMotorhead, just for information can you describe what you're trying to do with your game at a higher level? I've found that frequently the question "how do I do programming task X" is a proxy for a more fundamental question of "how do I accomplish game concept Y", and often the answer to THAT question is "don't do X, do Z instead." Or if nothing else, despite the low level of board activity here there actually are several people who love to exposit on Robotic in all its clumsy, quirky, occasionally brilliant glory, just waiting for a chance to show off what they know.

"Oh dammit I scared them away again, didn't I."
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#200 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,943
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 07 June 2016 - 09:13 PM

Wervyn, on 07 June 2016 - 09:58 PM, said:

Based on the description of the problem it sounds like MicMotorhead is trying to distinguish a bunch of copy-pasted enemies from some external code, trying to figure out which one the player touched. So the global robot doesn't really apply here. Plus, if you're going to have a global robot, it's probably going to have a unique name like "global" and perform a unique function, so addressing it by name shouldn't be a problem.


pfft, who cares about his problem, i'm trying to solve for the general case here =P
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#201 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 09:50 PM

Wervyn, on 07 June 2016 - 12:58 PM, said:

Based on the description of the problem it sounds like MicMotorhead is trying to distinguish a bunch of copy-pasted enemies from some external code, trying to figure out which one the player touched. So the global robot doesn't really apply here. Plus, if you're going to have a global robot, it's probably going to have a unique name like "global" and perform a unique function, so addressing it by name shouldn't be a problem.

@MicMotorhead, just for information can you describe what you're trying to do with your game at a higher level? I've found that frequently the question "how do I do programming task X" is a proxy for a more fundamental question of "how do I accomplish game concept Y", and often the answer to THAT question is "don't do X, do Z instead." Or if nothing else, despite the low level of board activity here there actually are several people who love to exposit on Robotic in all its clumsy, quirky, occasionally brilliant glory, just waiting for a chance to show off what they know.

"Oh dammit I scared them away again, didn't I."


Basically, I'm making this top-down, turn-based, somewhat "rogue like" RPG. Touching an enemy locks the players controls and engages you in a 1-on-1 encounter. All types of encounters with other robots - be it a treasure chest, a shopkeeper, a locked door - will similarly lock your controls.
The player will then use the interface to interact with whatever object was touched. You might choose to attack it, cast a spell on it, or whatever.

The way I've made it, it will never be possible to deal with more than one robot at a time. That is all on purpose.

My problem arose when I had several enemies of the same type on a map and engaged in combat with one. All enemies would add their damage together in one devastating blow no matter where on the map they were, and upon victory, all of them would die! I solved it by using the suggested ."@robotname" command. Now I simply call enemies "NMEinactive" normally, then rename the activated enemy to "NME", which is what my combat program recognizes for send commands.

There are still many things that seem difficult to handle, though. Right now I'm just beginning to make the magic system, where various effects have to be
checked and rolled against whatever the player attempts to use them on. I can probably figure it out, but I'm not sure my usual solutions are very, er... conventional...

One thing that I really hope there is a way to do is this:
When you make if-then statements or use inc/dec commands, can you add counters together in some mathematical way? It isn't quite enough for me to just be able
to say 'inc "strength" by "swordstrength"' ---- Can't I do stuff like say 'inc "damage" by "str"+"con"-"whateverotherstat"... you know, do some simple math to determine values, add counters together, etc. It seems that the way in which I can do so is extremely cumbersome??

Here's an example of some of my code, just so you can see how rudimentary my coding generally is:

: "waraxe"
set "$rhand" to "waraxe"
put "@waraxe.mzm" Image_file "[0]" at 2 17
set "str" to "basestr"
inc "str" by "waraxestr"
set "dex" to "basedex"
inc "dex" by "waraxedex"
set "$lhand" to "barehanded" *
put "@blank.mzm" Image_file "[0]" at 14 17*
set "agi" to "baseagi" *
set "def" to 0 *
% "war axe equipped"
end

(*=These lines simply unequip shields from the opposing hand and resets the stats that shields affect. This is because the
weapon equipped here is two-handed.)

What I'm doing here is that I have some characters with various stats. You choose one when you begin the game. Strength
and other stats are 'set' when you start a new scenario, and 'basestr' is the same value as 'str' from the beginning. All stats have corresponding 'base' values. The idea is that I'll increase 'basestr' when the character gets
permanently stronger, and increase 'str' when it is temporary, like when equipping a weapon. When the weapon is unequipped or another weapon replaces it, 'str' is reset to 'basestr' and the added to the 'str' value of the newly equipped item.
Trouble arises as soon as I want to have several items affect the 'str' stat and the player shifts them around, takes them off, on, etc... then I don't really know how to handle it elegantly.

I guess what I really, really want is a way to do 'if "x" >=< "y" then "dothis"' type code without actually CHANGING the involved values. I just want to add them together and check them for the sake of figuring out whether or not a diceroll is successful or how much damage is dealt, etc.

This post has been edited by MicMotorhead: 07 June 2016 - 10:06 PM

0

#202 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 10:08 PM

Dr Lancer-X, on 07 June 2016 - 10:13 PM, said:

pfft, who cares about his problem, i'm trying to solve for the general case here =P


Believe me, I'm just impressed I got quick responses of any sort at all! :(
0

#203 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 07 June 2016 - 10:41 PM

MicMotorhead, on 07 June 2016 - 05:50 PM, said:

Basically, I'm making this top-down, turn-based, somewhat "rogue like" RPG. Touching an enemy locks the players controls and engages you in a 1-on-1 encounter. All types of encounters with other robots - be it a treasure chest, a shopkeeper, a locked door - will similarly lock your controls.
The player will then use the interface to interact with whatever object was touched. You might choose to attack it, cast a spell on it, or whatever.

The way I've made it, it will never be possible to deal with more than one robot at a time. That is all on purpose.

My problem arose when I had several enemies of the same type on a map and engaged in combat with one. All enemies would add their damage together in one devastating blow no matter where on the map they were, and upon victory, all of them would die! I solved it by using the suggested ."@robotname" command. Now I simply call enemies "NMEinactive" normally, then rename the activated enemy to "NME", which is what my combat program recognizes for send commands.

There are still many things that seem difficult to handle, though. Right now I'm just beginning to make the magic system, where various effects have to be
checked and rolled against whatever the player attempts to use them on. I can probably figure it out, but I'm not sure my usual solutions are very, er... conventional...

One thing that I really hope there is a way to do is this:
When you make if-then statements or use inc/dec commands, can you add counters together in some mathematical way? It isn't quite enough for me to just be able
to say 'inc "strength" by "swordstrength"' ---- Can't I do stuff like say 'inc "damage" by "str"+"con"-"whateverotherstat"... you know, do some simple math to determine values, add counters together, etc. It seems that the way in which I can do so is extremely cumbersome??

Here's an example of some of my code, just so you can see how rudimentary my coding generally is:

: "waraxe"
set "$rhand" to "waraxe"
put "@waraxe.mzm" Image_file "[0]" at 2 17
set "str" to "basestr"
inc "str" by "waraxestr"
set "dex" to "basedex"
inc "dex" by "waraxedex"
set "$lhand" to "barehanded"
put "@blank.mzm" Image_file "[0]" at 14 17
set "agi" to "baseagi"
set "def" to 0
% "war axe equipped"
end

What I'm doing here is that I have some characters with various stats. You choose one when you begin the game. I got STRength
is 'set' when you start, and 'basestr' is the same value. The idea is that I'll increase 'basestr' when the character gets
permanently stronger, and increase 'str' when it is temporary, like when equipping a weapon. When the weapon is unequipped or another weapon replaces it, 'str' is reset to 'basestr' and the added to the 'str' value of the newly equipped item.
Trouble arises as soon as I want to have several items affect the 'str' stat and the player shifts them around, takes them off, on, etc... then I don't really know how to handle it elegantly.


What you're asking about are "expressions", which are basically a hacked in way of handling more complicated math without a bunch of intermediate commands. So consider the following:
inc "damage" by "('str'+'con'-'whateverotherstat')"

This does exactly what it looks like, but the catch is that whole math expression is inside a single string, so you don't get any real syntax highlighting, and if you mess something up it defaults to parsing it as a counter with a ridiculous name (i.e. zero). So definitely a powerful tool that you want to use here, but be careful to double check your code.

For your code, in terms of handling weapon equips and stat modifications I'd probably recommend something like this:
. "Whatever is handling selecting the hand and equipment starts here:"
set "$equip_item" to "waraxe"
set "$equip_slot" to "rhand"
goto "#equip"
set "$equip_item" to "blank"
set "$equip_slot" to "lhand"
goto "#equip"
. "Or perhaps"
send "equipbot" to "equip"
goto "#resetstats"
end
. "----"
: "#equip"
set "$&$equip_slot&" to "$equip_item"
put "@&$equip_item&.mzm" Image_file p00 at "&$equip_slot&_image_x" "&$equip_slot&_image_y"
goto "#return"

: "#resetstats"
set "str" to "('basestr'+'&$rhand&str'+'&$lhand&str')"
set "dex" to "('basedex'+'&$rhand&dex'+'&$lhand&dex')"
set "agi" to "('baseagi'+'&$rhand&agi'+'&$lhand&agi')"
set "def" to "('basedef'+'&$rhand&def'+'&$lhand&def')"
. "etc."
goto "#return"


I'm throwing a lot of concepts at you here but the basic idea is to show how you can take advantage of expressions, strings, and interpolation to compress your code into functional blocks and reduce a lot of repetition (and thus, a lot of surface area for bugs and inconsistencies to hide). Stuff in a string between ampersands gets directly interpolated as a value, and in the case of strings can be used to look up full or partial counter names for expressions. Single quotes in expressions are very similar, but specifically work only for numeric values. And these two syntaxes can be nested in an expression without a problem, so I can have a line like:
set "str" to "('basestr'+'&$rhand&str'+'&$lhand&str')"

Which since I set "$rhand" to "waraxe" (via $equip_slot and $equip_weapon, so that everything can call the same method), and "$lhand" to "blank", turns into
set "str" to "('basestr'+'waraxestr'+'blankstr')"

Or notice how this trick:
set "$&$equip_slot&" to "$equip_item"

essentially becomes the following on execution:
set "$rhand" to "waraxe"


This provides a much cleaner separation between code that's responsible for choosing a specific weapon and slot, code that's responsible for equipping a whatever to wherever, and code that's responsible for tallying up stats based on existing equipment. I'm also introducing subroutines, which you may not be familiar with yet, as a way to organize code segments that can be executed and then return execution to the original context; and showing how you can use strings and counters to treat them sort of like functions (though with a lots of asterisks since your function "arguments" are global, overwritable counters).

Edit: Oh right, don't forget about the following, and stuff like it, to set up constants for image loading:
set "rhand_image_x" 2
set "rhand_image_y" 17
set "lhand_image_x" 14
set "lhand_image_y" 17


MicMotorhead said:

Believe me, I'm just impressed I got quick responses of any sort at all! :(

The boards here are not, strictly speaking, dead. They just aren't very active anymore.

"I don't want to go on the cart! I feel happy!"
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#204 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 07 June 2016 - 11:41 PM

Thanks a lot!

I'm too tired to figure this stuff out now but I'm going to mess around with it some after I catch some sleep.

I have a feeling this particular bit of code you posted...

set "str" to "('basestr'+'&$rhand&str'+'&$lhand&str')"

... teaches me a whole bunch of useful stuff I should have known long ago!
0

#205 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 13 June 2016 - 10:21 PM

Allright, here I am again, not understanding Robotic!

Check this out:

write overlay c0f "&('ammostr'+'substr')& extra DMG to enemy" at 0 22

What I'm trying to do there is to simply display the sum of that bit of math in the overlay.
Since this works with single counters, like if the line had looked like this...

write overlay c0f "&substr& extra DMG to enemy" at 0 22

... then I don't understand why it doesn't work with a math expression.
I mean, ('ammostr'+'substr') is a valid expression, so why can't i put it
in ampersands?

I read the built in documentation about expressions and there's a bunch of
monumentally confusing examples, some of which involve ampersands,
but I understood none of those examples.

This post has been edited by MicMotorhead: 13 June 2016 - 10:26 PM

0

#206 User is online   Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 13 June 2016 - 10:27 PM

You shouldn't put an expression in ampersands to do that. The expression evaluates by itself—when you do &('ammostr'+'substr')&, what you're actually doing is evaluating the counter named [whatever ('ammostr'+'substr') evaluates to]. &counter& and ('counter') are essentially equivalent for counters.

example:

set "123" "99999"
set "counter" 123

. "test123"
write overlay c0f "test&counter&" 0 0

. "test123"
write overlay c0f "test('counter')" 0 1

. "test99999"
write overlay c0f "test&('counter')&" 0 2



set "$str" "some string"

. "testsome string"
write overlay c0f "test&$str&" 0 4

. "test0"
write overlay c0f "test('$str')" 0 5



set "$numstr" "456"

. "test456"
write overlay c0f "test&$numstr&" 0 7

. "test456"
write overlay c0f "test('$numstr')" 0 8


(sidenote: &$str& and ('$str') are not equivalent unless the string starts with a number)
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository
0

#207 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 13 June 2016 - 10:56 PM

I see, my understanding of what the ampersands do has been quite simplistic.
The way I though of them was simply "anything I put between two &'s will display
if possible." It made sense in my head to combine the logic of expressions like ('x'+'y')
with "&z&".
Forgot of course that I was using the 'write to overlay' command already!

What if, when I would normally write someting like:

* "Took &x& damage!"

Would I be able to simply write:

* "Took ('x'+'y') damage!"

if I want to add counters together, because normally I'd need the ampersands here, as I understand it.

Well,anyway, now I got yet another part of my game finally working correctly :(
So, thanks!

This post has been edited by MicMotorhead: 13 June 2016 - 11:01 PM

0

#208 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 14 June 2016 - 01:13 PM

MicMotorhead, on 13 June 2016 - 06:56 PM, said:

What if, when I would normally write someting like:

* "Took &x& damage!"

Would I be able to simply write:

* "Took ('x'+'y') damage!"

if I want to add counters together, because normally I'd need the ampersands here, as I understand it.


Yep, that's right. It probably takes a little bit of getting used to, the idea that you can evaluate a value in place pretty much anywhere. This leads to some pretty messy code that would make me cringe in other languages (well, it makes me cringe in MZX too), but is the only good way to get around some of the limitations. For example, MZX has no array variables, but you CAN do this:

set "array" to 40
loop start
set "array('loopcount')" to "('loopcount'*'loopcount'+'loopcount'+41)"
loop for "('array'-1)"


This sets "array" to 40 to represent the array length, and then "array20" to 461. Bonus fun fact: the "loop start/loop for X" syntax in MZX is the absolute WORST, it's one of the most counter-intuitive things in the language, since it ultimately works out to "loop for X+1 iterations". I've explained and complained about this at more length here. (Bonus bonus fun fact: this is an arithmetic sequence of 40 prime numbers, it's one of my favorites.)

Or, MZX has no switch/case statement, but you can do the following with labels:

input string "WHAT IS YOUR FAVORITE COLOR!"
goto "choice_&INPUT&"
. "default"
[ "&INPUT& ain't no color I ever heard of. But I'm not very smart."
goto "break"
: "choice_blue"
[ "Right, off you go then."
goto "break"
: "choice_red"
[ "The manliest of colors."
goto "break"
: "choice_green"
[ "The color of money."
goto "break"
: "choice_african swallow"
[ "AAAAAAAAaaaaaaaaa...."
: "break"
end


Here, trying to goto a label that doesn't exist is just a no-op. You actually used to be able to interpolate directly into a label definition too, such as : "label&variable&", but that was removed for speed (label lookup is faster if they aren't constantly changing under you), and because no one had a good reason to do something like that.

For the most part, you can think of &var& and ('var') as basically the same thing, and they can both be plugged in pretty much anywhere. Trying to use both at once, a la &('var')& or ('&$var&') is a nested, double evaluation, and while there are reasons you might want to do this (particularly the second one with the string), you do want to be careful and clear about what you're actually asking for. To break down their differences:
  • &var& - Lexical evaluation. Pros: Evaluates strings. Cons: Not nested, single value only.
  • ('var') - Numeric evaluation. Pros: Nestable, combines with expressions. Cons: Numeric data only.

To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#209 User is offline   MicMotorhead 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 11-April 12
  • Gender:Male
  • Location:Denmark

Posted 14 June 2016 - 11:13 PM

Hmm ok, I gotta admit that some of that is mildly confusing to me, but thanks for the explanation.
I'm starting to find a lot of areas of MZX where it doesn't quite make sense to me.

I'm getting this odd math problem right now.
I have a stat for my game. INT. It is set to 80 in my test environment.
('INT'/100*70) ought to output something like 56, but it outputs 0 ???
I made a board just to test math outputs and ('a'/100*70) does indeed output 70 like it should.
("a" being set to 100)
What on earth is the problem with the previous calculation? A bug? 70% of 80 is clearly 56, not zero!
This is starting to drive me positively mad :(

(EDIT: I noticed after playing aroud with my test board a bit longer that MZX possibly doesn't
understand decimals, thus reducing anything divided by too big a number to 0. Can this be true?
If so... wow... that's a pretty big limitation. Say it ain't so D: :laughing: )

This post has been edited by MicMotorhead: 14 June 2016 - 11:25 PM

0

#210 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 15 June 2016 - 12:58 AM

MicMotorhead, on 14 June 2016 - 07:13 PM, said:

Hmm ok, I gotta admit that some of that is mildly confusing to me, but thanks for the explanation.
I'm starting to find a lot of areas of MZX where it doesn't quite make sense to me.

I'm getting this odd math problem right now.
I have a stat for my game. INT. It is set to 80 in my test environment.
('INT'/100*70) ought to output something like 56, but it outputs 0 ???
I made a board just to test math outputs and ('a'/100*70) does indeed output 70 like it should.
("a" being set to 100)
What on earth is the problem with the previous calculation? A bug? 70% of 80 is clearly 56, not zero!
This is starting to drive me positively mad :(

(EDIT: I noticed after playing aroud with my test board a bit longer that MZX possibly doesn't
understand decimals, thus reducing anything divided by too big a number to 0. Can this be true?
If so... wow... that's a pretty big limitation. Say it ain't so D: :laughing: )


Correct! All MZX counters are 32 bit signed integer values, ranging from -2,147,483,648 to 2,147,483,647. There are a number of ways to represent fractional values but the classic IEEE float or double is not one of them. I recommend working out a scaled approach, essentially fixed point, represent 32.315 as 32315, and 32 as 32000 in whatever context needs that precision. Also check out the trigonometric functions section in the help for examples of how MZX deals with non-integer values.

In your specific case, you can get around the problem you're having by changing the order of operations. Instead of ('a'/100*70), try ('a'*70/100), you'll find things work a lot better for you in general if you multiply before you divide. Of course, you still have to watch out for integer overflow if your numbers get too big! But no one is going to claim MZX is anything but a quirky ball of limitations. A lot of that is no one has felt like investing the time to add it (I think an old proposal was to use "%var" to represent a float, but that still needs to be integrated with everything else in the code-base). Some of it is just nostalgia, we kind of like our ball of quirks and you can still get it to do what you want, if you invest some time in figuring it out. If nothing else playing around with the integer limitations will teach you a lot about data storage and representation, and maybe even why floating point isn't always the best solution for things once you understand how it works.

ETA: By the way, another major gotcha about expression handling that you'll probably want to know, expressions don't have any concept of "order of operations" as they're conventionally understood mathematically. That is, (4+5*3), which you would generally expect to evaluate as 19 because multiplication precedes addition, actually works out as 27 in MZX because it just evaluates everything from left to right. There's no real limitation here, you can wrap parentheses around things and do (4+(5*3)) just fine, but it's definitely not what you're used to, and I'm not sure of any other languages that work in a similar way, outside of very old programming languages like Forth running reverse-Polish notation (where's zzo38 at these days?). The main reason for this was to avoid user questions about how expressions should handle the order of things like '>=' or 'a' (bitwise AND) in the same context as more conventional operators like '+' and '*'. Expressions are hard enough to debug as it is without any syntax highlighting, so making the deterministic evaluation very straightforward (just read left to right and apply operators and operands) is easier to understand and reason about, even if it's non-standard.
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

Share this topic:


  • (8 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users