Jump to content
MakeWebGames

GetUserVariable question


Someone
 Share

Recommended Posts

Doing some testing to get a grip of how the engine works.

content.php

 

<?php
SetUserVariable('attack', 1050);
TableHeader("Player Stat");
echo 'Attack: '.GetUserVariable('attack').'<br />';
echo 'Defense:'.GetUserVariable('defense').'<br />';
echo 'Speed:'.GetUserVariable('spvvveedfff').'<br />';
TableFooter();
?>

 

This outputs

Player Stat

Attack: 1050

Defense:1050

Speed:1050

spvvveedfff is not a real variable at all but it returns the attack value.

Here is the config.xml that is used for this module

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.nw-engine.com/modules.xsd">
<module name="Abilities" version="0.1" author="Someone" description="blah" />
<variable name="attack" />
<variable name="defense" />
<variable name="speed" />

</configuration>

 

And how do I set a default value for uservariables

Link to comment
Share on other sites

Because you do it wrong, you should not use a string as first parameter but the define which will be automatically setup for you (during module installation) and stored in config/auto_defines.php

Your code should be:

<?phpSetUserVariable(attack, 1050);
TableHeader("Player Stat");echo 'Attack: '.GetUserVariable(attack).'';
echo 'Defense:'.GetUserVariable(defense).'';
echo 'Speed:'.GetUserVariable(spvvveedfff).'';
TableFooter();
?>

 

Yet, for me those should be stats and not user variables, for stats it's a bit differently handled.

User variable wiki: http://www.nw-engine.com/wiki/index.php/User_variable

Stats: http://www.nw-engine.com/wiki/index.php/UserStat

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...