• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 06:49
CET 12:49
KST 20:49
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners10Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!33$5,000+ WardiTV 2025 Championship6[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
Mech is the composition that needs teleportation t TL.net Map Contest #21: Winners Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win RotterdaM "Serral is the GOAT, and it's not close" 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
Constellation Cup - Main Event - Stellar Fest $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
[ASL20] Ask the mapmakers — Drop your questions BW General Discussion [BSL21] RO32 Group Stage BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review
Tourneys
[Megathread] Daily Proleagues [ASL20] Grand Finals [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile Should offensive tower rushing be viable in RTS games? Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1542 users

The Big Programming Thread - Page 916

Forum Index > General Forum
Post a Reply
Prev 1 914 915 916 917 918 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
November 06 2017 10:24 GMT
#18301
On November 06 2017 09:51 WarSame wrote:
I just saw the most unethical Github project ever. OAuth using 23andme so you can use demographic discrimination for access to a site.


I'm surprised they didn't call this project "GATTACA"...
Time is precious. Waste it wisely.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 06 2017 23:05 GMT
#18302
Ah... I just realized why that movie was called Gattaca... it's all of the DNA letters.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Programmer2
Profile Joined November 2017
9 Posts
November 09 2017 04:04 GMT
#18303
If you wanna make an RPG like game using C* and let's say you start the game with 10 damage and 10 HP and after you obtain an item it increases your attack damage by 5 and you want the program to tell you your new (which would then be your current) attack damage in a future battle and when you check your stats?

Do I need to make your starting attack damage of 10 a global variable then code the item to add 5 to it? Would that be an int? But then how would I get the program to remember the new stats?
Thaniri
Profile Blog Joined March 2011
1264 Posts
Last Edited: 2017-11-09 12:42:41
November 09 2017 05:11 GMT
#18304
I don't know what C* is but here is some pseudocode that might get you going.

class character{
int hpmax
int hpcurrent
int basedamage
array<items> items
}

class item{
int damage
}

//put this in the character class
function calculatedamage{
int temp = this.basedamage
for each item in items
temp += item.damage
return temp
}


A setup like this would calculate the total damage of the character every time it needs to be (for instance when attacking something)

A different setup might actually modify the damage stat of the character class itself.

I'm not a good enough programmer to tell you which is better.

edit: might as well mention that I like this solution cause it is pretty easy to also add in fun stuff like buffs and debuffs.
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
November 09 2017 06:44 GMT
#18305
I think he means C# but I could be wrong
TRUEESPORTS || your days as a respected member of team liquid are over
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
Last Edited: 2017-11-09 13:55:29
November 09 2017 08:32 GMT
#18306
If you want to make RPG's you might want to look into LPC to see how it's done (you can get all you need from here for example: http://discworld.starturtle.net/lpc/links/mudlinks.html ).


In an LPMud the mudlib is the support framework for the world. The MudOS driver provides the very basic fundamentals and the mudlib provides the features necessary to make a working game. The mudlib is what defines how most common objects work and what capabilities they have.

Discworld has created and maintains its own mudlib. The mulib was started in 1991 and has been under constant development ever since. Unlike some other distribution libs the Discworld lib is a working mudlib, used to run a very large LPMud. There are also about 20 other MUDs that use the lib or a derivative of it.

The Discworld mudlib goes beyond the norm with the number and variety of objects available and the level of detailed interaction that is possible with them. For example, books on Discworld can not only be read, they can be written on, they can be published and printed, you can even tear pages out of them. This kind of attention to detail, this immersive environment, is found throughout Discworld MUD.

The Discworld mudlib was first released in 1993 and the current version is available for download for free from the mud links section.

If you setup a MUD that uses the Discworld lib you may wish to join the dwcre and dwchat intermud channels (see documentation for details).


Another possibility is RenPy (if you also want graphics).
Time is precious. Waste it wisely.
Programmer2
Profile Joined November 2017
9 Posts
November 09 2017 17:50 GMT
#18307
On November 09 2017 15:44 emperorchampion wrote:
I think he means C# but I could be wrong


I thought C* and C# were the same thing? But the post above yours is in C# since the "//" (without the quotes) is how you add comments that won't show up when you run your program.
tofucake
Profile Blog Joined October 2009
Hyrule19151 Posts
November 09 2017 18:12 GMT
#18308
double slash comments are in just about every C based language. C* hasn't been developed or used since the early 90s, and I doubt very much anybody is asking about basic concepts in C*, as it's just a superset of C (so the fundamentals are the same) and C is easier to find information on.

C# is a C-based language that is more akin to Java than C. It is decidedly different from C*.
Liquipediaasante sana squash banana
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
November 09 2017 19:33 GMT
#18309
Huh TIL about C*
TRUEESPORTS || your days as a respected member of team liquid are over
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
Last Edited: 2017-11-10 00:04:28
November 10 2017 00:03 GMT
#18310
Damn, this all brought some nostalgia and now I wonder why no other language has adopted LPC's shadowing yet. It is such an awesome and powerful feature...

Basically, you can extend objects during their lifetime (yes, even after they've been initialized) and even remove those extensions from them when you want. Just imagine the possibilities! Objects having extra functionality only when you really need it and no longer than you need it (in C# it would be similar to adding/removing traits to objects on the fly).
Time is precious. Waste it wisely.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
November 10 2017 00:05 GMT
#18311
Question on entity framework, (C#.net): I've just recently started using EF. I've been doing a lot of googling, but I'm a bit stumped on this. Suppose I have three tables:

Student (StudentId,StudentName)
Class (ClassId,ClassName)
Grade (StudentId,ClassId,Grade)

I want to create a relationship between Student and Grade, and then a relationship between Class and Grade. The primary key in Grade is a composite key of StudentId and ClassId. You can't have a grade for a student that doesn't exist, nor a grade for a class that doesn't exist, right? Nor can you have two grades for the same student in the same class. Is there a way to create a relationship between these tables in EF? It's telling me I can't because the key in Student and Class don't match the key in Grade.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 10 2017 00:32 GMT
#18312
On November 10 2017 09:05 enigmaticcam wrote:
Question on entity framework, (C#.net): I've just recently started using EF. I've been doing a lot of googling, but I'm a bit stumped on this. Suppose I have three tables:

Student (StudentId,StudentName)
Class (ClassId,ClassName)
Grade (StudentId,ClassId,Grade)

I want to create a relationship between Student and Grade, and then a relationship between Class and Grade. The primary key in Grade is a composite key of StudentId and ClassId. You can't have a grade for a student that doesn't exist, nor a grade for a class that doesn't exist, right? Nor can you have two grades for the same student in the same class. Is there a way to create a relationship between these tables in EF? It's telling me I can't because the key in Student and Class don't match the key in Grade.


Hard to tell, but...if the error is telling you the Student and Class keys don't match the ones in Grade, does that mean you've set the Student and Class keys as the Foreign Keys? Should be other way around, like:

public class Grade
{
...
[ForeignKey="Student"]
[Column(Order=0]
public int StudentId { get; set; }

[ForeignKey="Class"]
[Column(Order=1]
public int ClassId { get; set; }
...
}


Been a while since I've done code-first though.
Average means I'm better than half of you.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
November 10 2017 00:37 GMT
#18313
Actually, I'm doing database first design. I was trying to add them in the EF diagram but couldn't get it to work because of that error. I added them on the SQL side and refreshed the model from the database, and that seemed to work. For some reason I was thinking there was some logical error with the relationships that EF doesn't support, but I guess it just needed to be done on the SQL side. Thanks!
Hanh
Profile Joined June 2016
146 Posts
November 10 2017 00:50 GMT
#18314
On November 10 2017 09:03 Manit0u wrote:
Damn, this all brought some nostalgia and now I wonder why no other language has adopted LPC's shadowing yet. It is such an awesome and powerful feature...

Basically, you can extend objects during their lifetime (yes, even after they've been initialized) and even remove those extensions from them when you want. Just imagine the possibilities! Objects having extra functionality only when you really need it and no longer than you need it (in C# it would be similar to adding/removing traits to objects on the fly).


How do references to objects through traits behave?
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
Last Edited: 2017-11-10 04:09:53
November 10 2017 03:56 GMT
#18315
On November 10 2017 09:50 Hanh wrote:
Show nested quote +
On November 10 2017 09:03 Manit0u wrote:
Damn, this all brought some nostalgia and now I wonder why no other language has adopted LPC's shadowing yet. It is such an awesome and powerful feature...

Basically, you can extend objects during their lifetime (yes, even after they've been initialized) and even remove those extensions from them when you want. Just imagine the possibilities! Objects having extra functionality only when you really need it and no longer than you need it (in C# it would be similar to adding/removing traits to objects on the fly).


How do references to objects through traits behave?


From the docs:


The standard shadow module also provides easy access to the original object. The variable shadow_who is set to the original object, so in the shadow object any call on the form shadow_who->function() goes to the original object function, even if it is shadowed in the shadow object.


This is pretty complicated. When you have a reference to an object and then you shadow it, it doesn't change the reference. What shadows do is mask object methods (or add new methods to it) in the runtime (shadows cannot be shadowed themselves, if you have multiple shadows masking the same methods and you apply them to the object the last shadow applied takes precedence).

Basically, any method call you make to the object will go to the shadow instead (if present). The most tricky part here are properties (which can't be shadowed but the same property can be declared in the shadow, shadow then uses its own property but all internal calls within the shadowed object will be using their own properties). You can also apply the same shadow to multiple objects.

It's very useful for game development (practically the only field LPC is being used) since this allows you to play around with player characters in some interesting ways.

Example:

If we have a player character (an object) and said character joins a guild or attains a profession that gives it new abilities or changes the way it behaves we simply add guild/profession shadow to the player. If the player quits the guild/profession we can simply remove specific shadow and the change is instantaneous. You can also set it up so that shadows are autoloaded and applied to the object on instantiation (when the player logs out and logs back in his shadows are re-applied to the character for example).

Example 2 (from the docs):

Assume for example that you want to redefine the gender of a player who's been affected by an evil spell of some kind. The function you want to shadow is called query_gender_string() and can be found in /std/living/gender.c. This is how you do it:


inherit "/std/shadow";

int
start(string pl_name)
{
return(objectp(shadow_me(pl_name)));
}

int
stop()
{
remove_shadow();
}

string
query_gender_string()
{
return "xxx";
}

// please notice that I've added both a start and a stop function for easy testing;
// these really aren't necessary as long as the shadow somehow calls shadow_me() with the target
// (either as a name or an object reference) as argument.
Time is precious. Waste it wisely.
Hanh
Profile Joined June 2016
146 Posts
November 10 2017 08:44 GMT
#18316
This can be done without direct support with design patterns Proxy & Decorator. I'm guessing the usage is too narrow to justify inclusion in a general purpose language.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-11-10 10:36:34
November 10 2017 10:36 GMT
#18317
Main place I've heard any real usage of it is debugging Ruby server code on the fly, allows you to test out behaviors instantly in a debugger. So I've heard.
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
November 10 2017 12:04 GMT
#18318
LPC creator went on to create a general purpose programming language. I wonder if he'll include shadowing in it:
https://pike.lysator.liu.se/
Time is precious. Waste it wisely.
shz
Profile Blog Joined October 2010
Germany2687 Posts
November 11 2017 00:19 GMT
#18319
On November 06 2017 09:51 WarSame wrote:
I just saw the most unethical Github project ever. OAuth using 23andme so you can use demographic discrimination for access to a site.


Wow
Liquipedia
Programmer2
Profile Joined November 2017
9 Posts
November 11 2017 03:20 GMT
#18320
On November 09 2017 14:11 Thaniri wrote:
I don't know what C* is but here is some pseudocode that might get you going.

class character{
int hpmax
int hpcurrent
int basedamage
array<items> items
}

class item{
int damage
}

//put this in the character class
function calculatedamage{
int temp = this.basedamage
for each item in items
temp += item.damage
return temp
}


A setup like this would calculate the total damage of the character every time it needs to be (for instance when attacking something)

A different setup might actually modify the damage stat of the character class itself.

I'm not a good enough programmer to tell you which is better.

edit: might as well mention that I like this solution cause it is pretty easy to also add in fun stuff like buffs and debuffs.


I tried to do that but I couldn't figure it out so I kept it simple: To increase your damage after getting your first item I did number1=number1+5

And to see the items you got I did an if statement that checks to see if two buttons are disabled it will show the item in your list of items. My original idea was to keep one button disabled then when that is enabled but then after clicking it it becomes disabled then you get the item but I couldn't figure out how to do that. So both buttons need to be disabled to get the item however I am making it so after clicking a button it becomes disabled.

So to illustrate my point: let's say button 4 is the button with the item, well the game starts off with that button disabled. In order to enable it you need to click on let's say button 6, after you do that, that button becomes disabled but button 4 becomes enabled then after clicking on button 4, that becomes disabled and you get your item. So now since both buttons are disabled that item gets added to your list of items but to the player they think they got the item from "completing" button 4.
Prev 1 914 915 916 917 918 1032 Next
Please log in or register to reply.
Live Events Refresh
CranKy Ducklings
10:00
Sea Duckling Open #140
CranKy Ducklings93
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 176
ProTech129
StarCraft: Brood War
Sea 7520
Horang2 3621
GuemChi 3257
Jaedong 732
actioN 400
Larva 387
Soma 312
Stork 243
Mini 239
BeSt 211
[ Show more ]
EffOrt 144
Killer 135
Backho 111
ToSsGirL 91
Hyun 87
Rush 69
Mind 48
PianO 35
NaDa 30
Sharp 29
Icarus 19
HiyA 15
sorry 12
soO 12
Bale 11
Sacsri 8
Terrorterran 4
Dota 2
Gorgc4237
singsing1652
XcaliburYe267
Counter-Strike
fl0m2549
zeus556
edward31
Heroes of the Storm
Khaldor143
Other Games
B2W.Neo687
Sick318
XaKoH 117
Fuzer 88
nookyyy 32
MindelVK18
Organizations
Counter-Strike
PGL130
StarCraft 2
WardiTV11
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH158
• StrangeGG 68
• LUISG 31
• Dystopia_ 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos2743
• Stunt940
Upcoming Events
IPSL
6h 11m
dxtr13 vs OldBoy
Napoleon vs Doodle
LAN Event
6h 11m
Lambo vs Clem
Scarlett vs TriGGeR
ByuN vs TBD
Zoun vs TBD
BSL 21
8h 11m
Gosudark vs Kyrie
Gypsy vs OyAji
UltrA vs Radley
Dandy vs Ptak
Replay Cast
11h 11m
Sparkling Tuna Cup
22h 11m
WardiTV Korean Royale
1d
LAN Event
1d 3h
IPSL
1d 6h
JDConan vs WIZARD
WolFix vs Cross
BSL 21
1d 8h
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
1d 21h
[ Show More ]
Wardi Open
2 days
WardiTV Korean Royale
3 days
Replay Cast
3 days
Kung Fu Cup
4 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
4 days
The PondCast
4 days
RSL Revival
4 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
5 days
WardiTV Korean Royale
5 days
RSL Revival
5 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
6 days
CranKy Ducklings
6 days
RSL Revival
6 days
herO vs Gerald
ByuN vs SHIN
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.